Button
Triggers an action or event, such as submitting a form or opening a dialog. Same markup and props in every style: switch the style in the header to see it change.
Variants
Use primary for the main action on a screen, and the quieter variants for everything else.
Sizes
Sizes come from the style's scale, and Customize → Density adjusts all of them together. Icon buttons need an aria-label.
Icons, disabled, links
Pass href and the React Button renders a link. A disabled link gets aria-disabled and leaves the tab order.
Installation
React, Vue and Svelte: add the component to your project with the CLI. It reads your framework from vin.json and also copies any component this one needs. Then import it:
npx @vinish/ui add buttonimport { Button, buttonClasses } from "@/components/vin/button";import Button, { buttonClasses } from "@/components/vin/button.vue";import Button, { buttonClasses } from "$lib/components/vin/button.svelte";The import paths assume the default folders: @/components/vin (React and Vue, with the usual @ → src alias) and $lib/components/vin (SvelteKit). Use your own if you chose another folder in init. How the Vue and Svelte versions pass values and content is in Frameworks.
Plain HTML: the classes come with the style's stylesheet. It needs no JavaScript.
API
From spec/button.json, which every framework version is tested against.
| Prop | Values | Default | In HTML |
|---|---|---|---|
variant | primarysecondaryoutlineghostdanger | primary | vin-btn--{value} |
size | smmdlgicon | md | vin-btn--{value} |
disabled | boolean | false | disabled attribute on <button>, aria-disabled="true" on <a> |
href | string | — | renders an <a class="vin-btn"> instead of a <button> |
Parts
| React, Vue, Svelte | HTML classes |
|---|---|
<Button> | .vin-btn.vin-btn--secondary.vin-btn--outline.vin-btn--ghost.vin-btn--danger.vin-btn--sm.vin-btn--lg.vin-btn--icon |
Accessibility
- Native <button> element, so Enter and Space work without JavaScript.
- type="button" by default so it never submits a form by accident.
- Icon-only buttons (size="icon") need an aria-label.
- Visible focus ring in every style and mode.
Customize
Saved in this browser. Style and accent are in the header.