Button#
Component <neo-button> is a styled, keyboard-activated button with variant, size, and icon-slot conventions shared across the kit.
The selected state's markup and its scoped CSS. The CSS is wrapped in <style>@scope { ... }</style> and applies to the preview only. Edits change the preview above, applied live while Sync is on, or when you click Patch or Replace. Patch morphs the preview; Replace swaps it outright.
Signals
Datastar signals declared in the selected state's markup. Change a value to drive the preview, applied live while Sync is on, or when you click Patch.
Reference#
Attributes #
| Name | Type | Default | Description |
|---|---|---|---|
variant | "primary" | "secondary" | "ghost" | "danger" | "anchor" | none | Visual style. Omit for the default neutral styling. |
disabled | boolean | false | Removes the host from the tab order and swallows clicks. |
size | "sm" | "lg" | none | Control-size step: sm compact, lg large. Omit for the default size. |
value | string | none | Selection value inside a <neo-buttongroup> . |
Events #
| Name | Detail | Bubbles | Description |
|---|---|---|---|
click | none | yes | Also fires on Enter / Space. |
CSS variables #
| Name | Default | Description |
|---|---|---|
--neo-button-bg | #ffffff | Background of the default neutral button. |
--neo-button-color | #111827 | Text color of the default neutral button. |
--neo-button-border-color | rgba(0, 0, 0, 0.12) | Border color of the default neutral button. |
--neo-button-hover-bg | rgba(0, 0, 0, 0.04) | Background on hover for the default neutral button. |
--neo-button-active-bg | rgba(0, 0, 0, 0.08) | Background while pressed (:active) for the default neutral button. Darker than hover. |
--neo-button-active-color | var(--neo-button-color) | Text color while pressed for the default neutral button. |
--neo-button-gap | 0.35rem | Gap between adjacent button content (icon and label). |
--neo-button-shadow | 0 1px 2px rgba(0, 0, 0, 0.1) | Resting box shadow. |
--neo-button-hover-shadow | 0 6px 16px rgba(0, 0, 0, 0.2) | Box shadow on hover. |
--neo-button-active-shadow | 0 1px 3px rgba(0, 0, 0, 0.14) | Box shadow while pressed. |
--neo-button-hover-lift | -1px | Vertical translateY offset on hover. Zeroed under reduced motion and while a popup is anchored open. |
--neo-button-active-lift | 1px | Vertical translateY offset while pressed. Zeroed under reduced motion and while a popup is anchored open. |
--neo-button-radius | var(--page-radius, 0.25rem) | Corner radius. |
--neo-button-padding | round(calc(var(--page-spacing, 0.25rem) * 2), 1px) round(calc(var(--page-spacing, 0.25rem) * 3.5), 1px) | Per-side padding, snapped to whole pixels so the used height stays an integer. |
--neo-button-primary-bg | #2563eb | Background of the primary variant. |
--neo-button-primary-color | #ffffff | Text color of the primary variant. |
--neo-button-primary-hover-bg | #1d4ed8 | Background on hover for the primary variant. |
--neo-button-primary-active-bg | color-mix(in srgb, var(--neo-button-primary-hover-bg), #000 8%) | Background while pressed for the primary variant. |
--neo-button-secondary-bg | rgba(0, 0, 0, 0.06) | Background of the secondary variant. |
--neo-button-secondary-color | currentColor | Text color of the secondary variant. |
--neo-button-secondary-hover-bg | rgba(0, 0, 0, 0.1) | Background on hover for the secondary variant. |
--neo-button-secondary-active-bg | rgba(0, 0, 0, 0.14) | Background while pressed for the secondary variant. |
--neo-button-ghost-bg | transparent | Background of the ghost variant. |
--neo-button-ghost-color | currentColor | Text color of the ghost variant. |
--neo-button-ghost-hover-bg | rgba(0, 0, 0, 0.06) | Background on hover for the ghost variant. |
--neo-button-ghost-active-bg | rgba(0, 0, 0, 0.1) | Background while pressed for the ghost variant. |
--neo-button-danger-bg | #dc2626 | Background of the danger variant. |
--neo-button-danger-color | #ffffff | Text color of the danger variant. |
--neo-button-danger-hover-bg | #b91c1c | Background on hover for the danger variant. |
--neo-button-danger-active-bg | color-mix(in srgb, var(--neo-button-danger-hover-bg), #000 8%) | Background while pressed for the danger variant. |
--neo-button-anchor-underline-offset | 0.25em | Underline offset for the anchor variant. |
--neo-button-focus-ring | currentColor | Focus-visible outline color. |
--neo-link-radius | 2px | Corner radius of the focus outline on the anchor variant and <a data-neo-link>. |
Examples#
Variants & states#
The six built-in variant values (default, primary, secondary, ghost, danger, anchor), the disabled state, and an icon-and-label composition.
Composed content#
A button can host richer markup when the action needs more context than a short label.