Back to Tooljet

Button — Rocket Design Spec

frontend/src/components/ui/Rocket/Button/Button.spec.md

3.20.154-lts5.6 KB
Original Source

Button — Rocket Design Spec

<!-- figma: https://www.figma.com/design/XQdM9x8x9YHcj1lUK8abUG/Rocket-components?node-id=4957-23692 --> <!-- measurements: https://www.figma.com/design/XQdM9x8x9YHcj1lUK8abUG/Rocket-components?node-id=5773-11679 --> <!-- synced: 2026-03-13 -->

Props

PropTypeValuesDefault
variantstringprimary | secondary | ghost | ghostBrand | outlineprimary
sizestringlarge | default | medium | smalldefault
dangerbooleanfalse
disabledbooleanfalse
loadingbooleanfalse
leadingVisualReactNodeicon element
trailingVisualReactNodeicon element
childrenReactNodelabel text
asChildbooleanrender delegation via Slotfalse

Sizes

ValueHeightFont sizeLine heightTailwind hTailwind text
large40px14px20pxtw-h-10tw-text-lg
default32px12px18pxtw-h-8tw-text-base
medium28px12px18pxtw-h-7tw-text-base
small20px11px16pxtw-h-5tw-text-sm

Horizontal padding per size:

  • large: tw-px-4 (16px)
  • default: tw-px-3 (12px)
  • medium: tw-px-3 (12px)
  • small: tw-px-2 (8px)

Icon gap: tw-gap-1.5 for large/default, tw-gap-1 for medium/small

Token Mapping

VariantElementStateFigma tokenToolJet class
primarybackgrounddefaultbutton/primarytw-bg-button-primary
primarybackgroundhoverbutton/primary-hoverhover:tw-bg-button-primary-hover
primarybackgroundpressedbutton/primary-pressedactive:tw-bg-button-primary-pressed
primarybackgrounddisabledbutton/primary-disableddisabled:tw-bg-button-primary-disabled
primarytext + iconallicon/on-solidtw-text-text-on-solid
primaryshadowdefaultElevations/100tw-shadow-elevation-100
primary+dangerbackgrounddefaultbutton/danger-primarytw-bg-button-danger-primary
primary+dangerbackgroundhoverbutton/danger-primary-hoverhover:tw-bg-button-danger-primary-hover
primary+dangerbackgroundpressedbutton/danger-primary-pressedactive:tw-bg-button-danger-primary-pressed
primary+dangerbackgrounddisabledbutton/danger-primary-disableddisabled:tw-bg-button-danger-primary-disabled
secondarybackgrounddefaultbutton/secondarytw-bg-button-secondary
secondarybackgroundhoverbutton/secondary-hoverhover:tw-bg-button-secondary-hover
secondarybackgroundpressedbutton/secondary-pressedactive:tw-bg-button-secondary-pressed
secondarybackgrounddisabledbutton/secondary-disableddisabled:tw-bg-button-secondary-disabled
secondaryborderdefaultborder/accent-weaktw-border tw-border-border-accent-weak
secondarytext + icondefaulticon/brandtw-text-text-brand
secondaryshadowdefaultElevations/100tw-shadow-elevation-100
secondary+dangerborderdefaultborder/danger-weaktw-border-border-danger-weak
secondary+dangertext + icondefaulticon/dangertw-text-text-danger
ghostbackgroundhoverhover:tw-bg-interactive-hover
ghostbackgroundpressedactive:tw-bg-interactive-selected
ghosttext + icondefaulticon/strongtw-text-text-medium
ghostBrandbackgroundhoverhover:tw-bg-interactive-hover
ghostBrandbackgroundpressedactive:tw-bg-interactive-selected
ghostBrandtext + icondefaulticon/brandtw-text-text-brand
outlinebackgrounddefaultbutton/outlinetw-bg-button-outline
outlinebackgroundhoverbutton/outline-hoverhover:tw-bg-button-outline-hover
outlinebackgroundpressedbutton/outline-pressedactive:tw-bg-button-outline-pressed
outlineborderdefaultborder/weaktw-border tw-border-border-weak
outlinetext + icondefaulticon/strongtw-text-text-medium
allfocus ringfocusinteractive/focus-outlinefocus-visible:tw-ring-2 focus-visible:tw-ring-[var(--interactive-focus-outline)] focus-visible:tw-ring-offset-1
allcursordisableddisabled:tw-pointer-events-none disabled:tw-opacity-50
allicon (svg/img)disableddisabled:[&_svg]:tw-grayscale disabled:[&_img]:tw-grayscale

Slots

  • leadingVisual — optional ReactNode icon, rendered before label. Hidden when loading=true.
  • children — required, label text. Hidden when loading=true.
  • trailingVisual — optional ReactNode icon, rendered after label. Hidden when loading=true.
  • When loading=true: show <Loader2 /> (lucide-react) spinning icon centred. Replace with <Spinner /> once Rocket Spinner component is built.

CVA Shape

Shape A — variants + sizes

Uses CVA compoundVariants for the danger boolean modifier on primary and secondary variants.

Notes

  • Uses shadcn Button as structural base (Slot/asChild, forwardRef). All styling overridden by Rocket CVA via tailwind-merge.
  • asChild prop enables render delegation via shadcn's built-in @radix-ui/react-slot.
  • danger modifier applies to: primary (→ danger-primary tokens), secondary (→ danger border/text). Ghost, ghostBrand, outline have no danger variant in Figma.
  • loading state: hides content, shows centred Loader2 icon spinning. Loader2 is a stand-in until Rocket Spinner is built.
  • Font: IBM Plex Sans Medium — handled by global body font, no explicit font-family class needed.
  • Elevation/100 shadow on primary + secondary only (not ghost/ghostBrand/outline).
  • Border radius: tw-rounded-md (6px) for all sizes.