Components
Button
A native button with tones, variants, sizes, icons, icon-only metrics, press-and-hold repeat and a render prop for links, plus the rules every Buttons component shares.
import { Button } from '@salmonui/buttons/button';
import '@salmonui/buttons/button/styles.css';
<Button tone="primary" onClick={save}>Save</Button>;
Button renders a native <button> (APG Button). It is stateless: there is
nothing to control, and its events are the native ones (onClick, onFocus,
...) plus onRepeat; the pressed state lives on
ToggleButton. Its label is children, any
React node; HTML strings are never rendered. ref points at
the <button>, so ref.current.focus() and ref.current.click() cover
imperative focus and activation; there are no component methods.
Tones, variants and sizes
tone:'neutral'(default),'primary','success','warning','danger','info'. The five non-neutral tones are the theme seeds; there is no other color input.variant:'solid'(default),'outline','ghost','link'and'chip'(see Chips). Every tone and variant pair meets 4.5:1 text contrast in light and dark.size:'sm','md'(default),'lg'. It picks one of three fixed metric sets (24, 32 or 40 px tall), and the theme'sdensity: 'compact'tightens each of them by 4 px (see Density); usesize="lg"for larger touch targets.
Every state is a data-* styling hook on .salmon-button: data-variant,
data-tone, data-size, data-icon-only, data-loading, data-pressed,
data-floating. Keyboard focus shows a :focus-visible ring from the
theme's focus color; :hover and :active change the fill.
Button tones, variants and sizes
Open demoEvery tone and variant (the contrast matrix), the three sizes, icons, an icon-only button with its name and tooltip, a disabled button, keyboard activation and a link rendered through render.
Icons and icon-only buttons
iconStart and iconEnd take any React node and render it as a decorative
(aria-hidden) part before or after the label. They are logical: in a
dir="rtl" container iconStart sits on the right. Icon
classes and fonts are not used.
iconOnly gives square metrics. Its props type then requires aria-label or
aria-labelledby, and a development warning names the button when both are
missing at runtime.
<Button iconOnly aria-label="Delete" iconStart={<TrashIcon />} tone="danger" variant="ghost" />
Press and hold
repeat turns on press-and-hold repeat. The first activation is the
native onClick; each repeat while the button is held calls
onRepeat({ count, source }). repeat.delay (default 400 ms) is the
hold time before the first repeat and repeat.interval (default 100 ms) the
time between repeats; a held Space or Enter repeats on the same timer, and
operating system key repeats are ignored. Timers live in refs and
stop on release, pointer leave, pointercancel, key up and blur.
Press and hold to repeat
Open demoA quantity stepper whose buttons repeat while held, with the default 400 ms delay and a custom delay and interval.
Keyboard, forms and links
- Enter and Space activate, Tab moves focus: native
<button>behavior. Holding the key repeats whenrepeatis set. typedefaults to"button", so a button inside a form never submits by accident; passtype="submit"ortype="reset"explicitly.name,value,formandformActionpass through.disabledis the native attribute, so<fieldset disabled>disables the button too.renderswaps the element: it receives every computed prop (class names,data-*, ARIA, handlers,ref, children) and must spread them. On a non-button elementdisabledbecomesaria-disabled="true"with an inert click handler; an element that is neither a link nor a button getsrole="button",tabIndex={0}and Enter / Space activation.
<Button variant="link" render={(props) => <Link {...props} to="/orders" />}>Orders</Button>
titlepasses through as the tooltip; a Tooltip component belongs to a later category.
Shared rules
classNameis appended aftersalmon-buttonandstyleis merged; every other DOM prop (id,aria-*,data-*, event handlers) goes to the<button>. Built-in handlers run after yours and are skipped when yours callsevent.preventDefault().- State is controlled through props; the components never write storage. There are no lifecycle events or teardown methods: use effects.
- Built-in strings are props with English defaults:
loadingLabelandprogressLabelhere,menuLabelon the split button. - Motion is one fixed CSS transition, off under
prefers-reduced-motion; there is no ripple and no animation API. Theming is one theme with five seeds and a color scheme. - Every component renders on the server and hydrates without warnings.
axe-core is clean in light, dark and RTL and the ARIA is native
<button>semantics.
Button attributes, classes and server rendering
Open democlassName and style on a Button, DOM attributes passed through to the native button, a handler that vetoes the built-in toggle with preventDefault, and a status that shows the demo was rendered on the server and then hydrated.
Rendering:
Not included
- No shape props: round and rounded-corner buttons are not offered; radius
is system-owned and
floatingbuttons are circular. - No full-width prop: use
style={{ width: '100%' }}. - No icon above or below the label; compose the stack inside
children. typedefaults to"button", not the HTML"submit".
Performance budgets
The Buttons families are gated by npm run bundle:check and their browser
and SSR specs: @salmonui/buttons/button is at most 3.5 KB
gzip (Button alone 1.55 KB) and never pulls menu, overlay or positioning
code; the Menu family is at most 9.6 KB; @salmonui/buttons/tag-group loads
4.15 KB first and its drag code only on the first drag. A toggle paints
within 16 ms, an arrow key in a 50-item ToggleButtonGroup or a 1,000-item
menu within 8 ms, and 100 Buttons render on the server in under 5 ms; a
closed MenuButton renders the same markup whatever its item count.
Extracting the shared primitives kept every Data Grid budget unchanged;
the grid keeps its smaller private menu code instead of the
general primitives. The long menu demo
shows the open time of a 1,000-item menu on your machine, and the demo below
runs the SSR measurement in your browser.
Server rendering cost
Open demoRuns React's renderToString in the browser over 100 Buttons and a closed MenuButton with 100 and 1,000 items, showing the time per render and that the closed menu's markup does not grow with its items.
Press the button to run the measurement in this browser.
API reference
@salmonui/buttons/button: Button,
ToggleButton, ButtonGroup, ToggleButtonGroup and their types
(ButtonProps, ButtonTone, ButtonVariant, ButtonSize,
ButtonFloatingPosition, ButtonRepeatOptions, ButtonRepeatEvent,
ButtonRenderProps).