Skip to content
Dalvan UI

Button

Use a button to perform an action such as saving a record, opening a dialog, or submitting a form.

<button type="button" class="dv-button dv-color-primary dv-appearance-solid dv-appearance-interactive">
  <span class="dv-button__leading" aria-hidden="true">
    <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 4v12M4 10h12" /></svg>
  </span>
  Button
  <span class="dv-button__trailing" aria-hidden="true">
    <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 4 6 6-6 6" /></svg>
  </span>
</button>

Usage

After setting up the CSS, apply dv-button to a native <button>. Use links for navigation to another URL.

<button type="button" class="dv-button">Save</button>

Examples

Appearance

Use solid for the primary action and subtle for secondary actions. Plain starts with palette-colored text, ghost inherits the text color, and text stays transparent on hover. Paper uses the paper surface. Without an appearance class, the button starts with a transparent background and inherits its text color.

<button type="button" class="dv-button dv-color-primary">Base only</button>
<button type="button" class="dv-button dv-color-primary dv-appearance-solid dv-appearance-interactive">solid</button>
<button type="button" class="dv-button dv-color-primary dv-appearance-subtle dv-appearance-interactive">subtle</button>
<button type="button" class="dv-button dv-color-primary dv-appearance-plain dv-appearance-interactive">plain</button>
<button type="button" class="dv-button dv-color-primary dv-appearance-ghost dv-appearance-interactive">ghost</button>
<button type="button" class="dv-button dv-color-primary dv-appearance-text dv-appearance-interactive">text</button>
<button type="button" class="dv-button dv-color-primary dv-appearance-paper dv-appearance-interactive">paper</button>

Palette

Choose one palette independently of appearance. Use danger for destructive actions and pair warning or success with a clear action label to communicate meaning.

<button type="button" class="dv-button dv-color-primary dv-appearance-solid dv-appearance-interactive">primary</button>
<button type="button" class="dv-button dv-color-neutral dv-appearance-solid dv-appearance-interactive">neutral</button>
<button type="button" class="dv-button dv-color-success dv-appearance-solid dv-appearance-interactive">success</button>
<button type="button" class="dv-button dv-color-warning dv-appearance-solid dv-appearance-interactive">warning</button>
<button type="button" class="dv-button dv-color-danger dv-appearance-solid dv-appearance-interactive">danger</button>

Sizes

Medium is the default. Choose xs for compact icon actions, sm for dense toolbars, and lg for prominent or touch-first actions. With default tokens, their single-line heights are 24, 32, 40, and 56 px.

<button type="button" class="dv-button dv-button--xs dv-color-primary dv-appearance-solid dv-appearance-interactive">xs</button>
<button type="button" class="dv-button dv-button--sm dv-color-primary dv-appearance-solid dv-appearance-interactive">sm</button>
<button type="button" class="dv-button dv-color-primary dv-appearance-solid dv-appearance-interactive">md</button>
<button type="button" class="dv-button dv-button--lg dv-color-primary dv-appearance-solid dv-appearance-interactive">lg</button>

Width

An unmodified button fits its content. Wide sets a minimum width of 10rem, capped by the available width. Full width fills its container. Use one width or shape modifier per button.

<button type="button" class="dv-button dv-color-primary dv-appearance-solid dv-appearance-interactive">Auto width</button>
<button type="button" class="dv-button dv-button--wide dv-color-primary dv-appearance-solid dv-appearance-interactive">Wide</button>
<button type="button" class="dv-button dv-button--full-width dv-color-primary dv-appearance-solid dv-appearance-interactive">Full width</button>

Icons and shape

Use leading and trailing slots before and after the label. The slots follow document direction. Square fixes both dimensions to the button height and is intended for icon-only actions. Min-square sets minimum dimensions and grows to fit longer labels. Give icon-only buttons an accessible name.

<button type="button" class="dv-button dv-color-primary dv-appearance-solid dv-appearance-interactive">
  <span class="dv-button__leading" aria-hidden="true">
    <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 4v12M4 10h12" /></svg>
  </span>
  Add item
</button>
<button type="button" class="dv-button dv-color-primary dv-appearance-subtle dv-appearance-interactive">
  Continue
  <span class="dv-button__trailing" aria-hidden="true">
    <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="m7 4 6 6-6 6" /></svg>
  </span>
</button>
<button type="button" class="dv-button dv-button--square dv-color-primary dv-appearance-solid dv-appearance-interactive" aria-label="Add">
  <span class="dv-button__leading" aria-hidden="true">
    <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 4v12M4 10h12" /></svg>
  </span>
</button>
<button type="button" class="dv-button dv-button--min-square dv-color-primary dv-appearance-subtle dv-appearance-interactive">10</button>
<button type="button" class="dv-button dv-button--min-square dv-color-primary dv-appearance-subtle dv-appearance-interactive">100 items</button>

Interaction and disabled state

Add dv-appearance-interactive for hover and pressed styling. Tab to an enabled button to see its focus ring. The native disabled attribute prevents activation and removes the button from sequential keyboard navigation.

<button type="button" class="dv-button dv-color-primary dv-appearance-solid dv-appearance-interactive">Interactive</button>
<button type="button" class="dv-button dv-color-primary dv-appearance-solid">Static appearance</button>
<button type="button" class="dv-button dv-color-primary dv-appearance-solid dv-appearance-interactive" disabled>Unavailable</button>

Form actions

Use type="submit" for the primary form action and type="reset" to restore defaults. Edit the project name and activate Reset to try it. The playground above also demonstrates submit behavior.

<form>
  <label>Project <input name="project" value="Dalvan" /></label>
  <button type="reset" class="dv-button dv-color-primary dv-appearance-subtle dv-appearance-interactive">Reset</button>
</form>

API reference

OptionClass or attributeBehavior
Basedv-buttonApply to a native button. The base uses medium label typography, no border, and inherited text color.
Sizedv-button--xsdv-button--smdv-button--mddv-button--lgUse one. Defaults to md. Size sets typography, icon size, spacing, and padding.
Width and shapedv-button--widedv-button--full-widthdv-button--squaredv-button--min-squareUse one. Defaults to intrinsic width. Square sizing is based on one line height plus twice the effective block padding.
Icon slotsdv-button__leadingdv-button__trailingOptional direct children. Their SVGs inherit the current text color when authored with currentColor.
Palettedv-color-primarydv-color-neutraldv-color-successdv-color-warningdv-color-dangerUse one. Omitting the class keeps the surrounding palette context.
Appearancedv-appearance-soliddv-appearance-subtledv-appearance-plaindv-appearance-ghostdv-appearance-textdv-appearance-paperUse one. The base button has no explicit appearance.
Interactiondv-appearance-interactiveOpt in to the active appearance’s hover and pressed styles.
Native behaviortypedisabledformnamevalueUse button for scripting, submit to submit the associated form, and reset to restore initial form values. HTML defaults to submit when type is omitted.
Accessible nameButton textaria-labelaria-labelledbyUse meaningful visible text or supply a name for icon-only controls.

Customization

Use component custom properties for a one-off override or apply the same properties in a reusable class. Change the shared label, radius, or palette tokens on a parent theme when several components should follow the same design.

<button type="button" class="dv-button dv-button--wide dv-color-primary dv-appearance-solid dv-appearance-interactive" style="--dv-button-wide-min-inline-size: 14rem; --dv-button-padding-block: var(--dv-space-150); --dv-button-gap: var(--dv-space-150); --dv-icon-size: 1.25rem;">
  <span class="dv-button__leading" aria-hidden="true">
    <svg viewBox="0 0 20 20" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M10 4v12M4 10h12" /></svg>
  </span>
  New project
</button>

CSS custom properties

PropertyEffect and defaults
--dv-button-padding-blockBlock padding. Defaults by size to space-50, space-75, space-100, and space-150.
--dv-button-padding-inlineInline padding. Defaults by size to space-75, space-100, space-150, and space-250. Slots reduce padding on their corresponding side.
--dv-button-gapSpace between label and slots. Defaults by size to space-50, space-75, space-100, and space-100.
--dv-button-wide-min-inline-sizeMinimum width for the wide modifier. Defaults to 10rem and is capped at the container width.
--dv-slot-gutterShared inset deducted from block padding and the medium radius. Defaults to 0px.
--dv-radius-md / --dv-radius-smShared corner radius and minimum radius for the button.
--dv-font-family-label / --dv-font-weight-labelShared label family and weight.
--dv-font-size-label-{size} / --dv-line-height-label-{size}Shared type size and line height for xs, sm, md, or lg.
--dv-icon-size / --dv-icon-size-label-{size}Override the icon size on one button, or adjust the label icon token for a size.
--dv-color-borderShared color used by the keyboard focus outline.