Button
The Button component is a fundamental interactive element designed to trigger actions and provide clear visual feedback. It supports multiple variants, sizes, and states to match various UI requirements.
Quick Links
Installation
Install the button individually or as part of the complete @aristobyte-ui library.
Installation of Button
The above command is for individual installation of Button only. You may skip this step if @aristobyte-ui is already installed globally.
Package Manager
Individual Package
Install only the button if you need specific functionality.
Full Library
Skip this if you have the complete @aristobyte-ui already installed.
Import
Choose between individual package imports or global library imports based on your project's needs and bundle size requirements.
Import Button
The Button component is a core interactive element in the AristoByte UI library, offering a consistent and accessible way to trigger actions. It supports multiple variants and states to align with your brand and interaction patterns. Import it as shown below to streamline call-to-action elements across your application:
Import Method
Individual Package
Import directly from the button package for optimal tree-shaking and smaller bundle sizes.
Recommended for component-specific usage
Global Library
Import from the main library package when using multiple components from AristoByte UI.
Recommended for component-specific usage
Basic Usage Example
Basic implementation of the component using default properties. Suitable for general-purpose interactions.
Button Variants
Buttons can adopt different colors (e.g., primary, secondary, success, warning, error) to reflect status or brand semantics during loading phases.
Preview
Guidelines
Primary for highest-priority, single action per view.
Secondary/tertiary for less prominent alternatives.
Use neutral variants for contextual actions that should not compete visually with CTAs.
Reserve error and warning variants for flows that require explicit user acknowledgement.
Interaction Patterns
Do not stack multiple primaries together.
Use destructive (error) variant only for irreversible ops.
Instrument variant usage to track UX patterns and detect misuse across large apps.
Provide clear migration notes when changing the default variant mapping in a major release.
Operational Guidelines
Button Appearance
The appearance prop defines the visual style of the button surface. Choose between solid, outline, outline-dashed, no-outline, and glowing to adapt to different UI contexts. While variant conveys semantic intent (e.g., primary, success), appearance controls the decorative rendering layer. This allows you to decouple behavior from style and maintain a more flexible component structure.
Preview
Guidelines
Use solid for CTAs; outline for secondary/inverse surfaces.
Use dashed/ghost patterns for low-emphasis utilities.
Prefer no-outline when embedding buttons into dense UI panels to minimize stroke noise.
Use glowing sparingly and reserve for micro-interactions or marketing surfaces only.
Design Considerations
Avoid glowing for critical or enterprise contexts.
Maintain sufficient hit affordance with no-outline.
Avoid heavy box-shadow/glow on many elements simultaneously to keep paint budgets reasonable.
Provide CSS-only fallbacks for appearance options to support environments without full JS hydration.
Performance & Behavior
Button Sizes
The Button component supports multiple size variants to match various UI needs, from compact to full-scale buttons.
Preview
Guidelines
Use smaller sizes for dense toolbars and compact UIs.
Use larger sizes for primary CTAs and mobile ergonomics.
Prefer consistent padding tokens across sizes to maintain rhythm across components.
Scale icons and spinner assets proportionally when changing size to avoid visual imbalance.
Design Considerations
Keep size consistent within the same context/surface.
Respect minimum hit area (~44×44px) for touch targets.
Provide clear size mapping in component docs so consumers can programmatically choose sizes.
Avoid hard-coded font sizes inside buttons; derive from typography tokens for theme compliance.
Implementation Notes
Disabled State
Use the disabled prop to visually and functionally disable buttons, preventing user interaction when needed.
Preview
Guidelines
Gate actions during async processing or unmet prerequisites.
Prevent destructive ops when user lacks authorization.
Disable during automatic retries or pending network reconciliation to avoid duplicate side-effects.
Conditionally disable when dependent form fields are invalid or validation is in-flight.
Usage Scenarios
Pair with tooltip or helper text to explain why it's disabled.
Maintain focus order; use aria-disabled for non-native buttons.
Expose semantic attributes (data-disable-reason) for telemetry and test automation.
Ensure disabled visuals are covered by unit/integration tests to prevent regressions.
Developer Tips
Border Radius
Control the corner radius of buttons using predefined shape tokens or custom values for seamless UI integration.
Preview
Guidelines
Align radius with product-wide shape semantics.
Use sharper corners for enterprise-dense layouts.
Use tokenized radius values to preserve cross-component consistency.
Consider platform affordances (iOS vs Android metaphors) when choosing extreme radii for mobile surfaces.
Visual Guidance
Avoid mixing multiple radii in one action cluster.
Maintain consistent radius across button + dropdown combos.
When theming, provide a clear override strategy to prevent accidental radius fragmentation.
Verify radius rendering at scale with visual regression snapshots to catch clipping issues.
Best Practices
Buttons with Icon
Pass an icon component via the icon.component prop and choose its position with icon.align. Icons support both left and right alignment and can be used alongside a loading spinner. To render an icon-only button, simply omit the children.
Preview
Guidelines
Use icons to reinforce meaning, not replace labels.
Icon-only buttons require accessible labels (aria-label).
Prefer a single icon library for consistency in stroke/weight across the UI.
Align icon metrics to text baseline to avoid optical misalignment in mixed-size buttons.
Visual Guidance
Keep icon size aligned with text height.
Ensure consistent spacing between icon and label.
Provide accessible name via aria-label when children are omitted.
Avoid animating icon layout shifts during label/content changes to prevent reflow.
Accessibility & Implementation
Loading State
The isLoading state provides feedback during asynchronous operations. It disables interaction and shows a spinner.
Preview
Guidelines
Apply for async tasks expected to exceed ~500ms.
Lock repetitive triggers to prevent duplicate requests.
Use loading states for multi-step workflows where intermediate state persists across screens.
Prefer inline loaders rather than full-overlay loaders for non-blocking operations.
When to Apply
Swap label to progress-friendly copy (e.g., “Saving…”).
Restore focus to the button on completion for continuity.
Provide ARIA live updates where appropriate to announce completion to assistive tech.
Ensure spinner animation is paused or simplified in low-power modes.
Continuity & UX
Button Group
Group multiple Button components into a single logical unit with shared styling and configuration. Use ButtonGroup to automatically propagate common props like variant and size across all children. Only Button elements are accepted as valid children, ensuring consistency and preventing unintended usage.
Preview
Guidelines
Cluster mutually related actions (e.g., formatting).
Use for mode-switching or segmented controls.
Apply for quick-action rows where grouping reduces cognitive load.
Use grouped buttons for responsive toolbars that collapse into menus on narrow viewports.
Usage Scenarios
Preserve logical order and consistent sizes.
Support arrow-key navigation for accessibility.
Ensure focus ring and selected-state visuals are propagated consistently.
Do not mix unrelated actions inside a single group; prefer contextual separation.
Interaction Patterns
Button Group Variant
Utilize the variant prop to apply consistent styling across all grouped buttons. Supported variants include default, primary, secondary, success, error, and warning, offering design cohesion for critical and contextual actions.
Preview
Guidelines
Apply one coherent variant per group.
Use neutral/default for mixed-importance utilities.
Avoid variant inheritance ambiguity; document precedence rules for group vs child.
Use variant mapping to align with product-level semantic tokens for analytics consistency.
Design Consistency
Avoid mixing semantic variants within one group.
Ensure contrast remains accessible on all states.
Add visual badges or separators when groups contain a mix of semantic importance to avoid misclicks.
Provide clear migration guidance if variant palettes change between versions.
Best Practices
Button Group Size
The size prop defines the uniform sizing of all buttons within the group. Choose from xsm, sm, md, lg, or xlg to ensure spatial consistency and scalability across various UI breakpoints or interaction densities.
Preview
Guidelines
Sync size with nearby inputs and controls.
Use larger sizes for touch-first contexts.
Use group sizes to enforce visual parity across dynamic button sets.
Prefer size tokens that map directly to spacing and typography scales.
When to Use
Do not mix sizes inside the same group.
Respect vertical rhythm across stacked groups.
Expose size-related CSS variables for consumer overrides when necessary.
Document responsive size behavior (e.g., auto-scaling on smaller viewports).
Implementation Notes
Button Group Radius
Control the curvature of button edges within the group using the radius prop. Available values include none, sm, md, lg, and full. This allows the group to visually align with the overall interface shape semantics, especially in rounded or sharp UI layouts.
Preview
Guidelines
Match group radius to global container shape tokens.
Use full for pill-style segmented controls.
Apply appropriate clipping rules to avoid adjacent element overlap when using large radii.
Ensure consistent radius behavior for first/last children when dynamic children are added/removed.
Visual Consistency
Avoid mixed radii within a single group.
Ensure first/last items visually cap the group correctly.
Provide utilities to normalize border-radius when combining with external wrappers.
Validate radius combinations visually in both LTR and RTL contexts.
Best Practices
Button Group Alignment
Configure the layout direction of buttons using the align prop. Set it to horizontal (default) to arrange buttons side-by-side, or vertical to stack them top-to-bottom. This is useful for adapting button groups to different layout contexts, such as toolbars or form actions.
Preview
Guidelines
Horizontal for toolbar-like interactions.
Vertical for narrow columns and mobile stacks.
Switch alignment responsively for smaller breakpoints to preserve touch targets.
Consider grouping alignment with adjacent layout components (inputs, labels) for visual coherence.
Layout Strategies
Mirror alignment with surrounding layout flow.
Maintain consistent spacing between grouped items.
When stacking vertically, ensure accessible hit area and consistent vertical rhythm.
Support reverse ordering for RTL locales and document expected behavior.
Design Considerations
Disabled Button Group
Apply the disabled prop on the ButtonGroup component to disable all nested buttons in a unified manner. This ensures consistent visual feedback and prevents individual interaction without modifying each button separately.
Preview
Guidelines
Disable an entire cluster when upstream state blocks all.
Use to prevent partial interaction in multi-step flows.
Use group-level disabling for transactional flows awaiting backend confirmation.
Leverage disabled groups during role-based access reviews to reduce per-button overrides.
Operational Scenarios
Communicate why the group is disabled (tooltip/helper).
Allow granular overrides only when explicitly required.
Expose a single override API for exceptions to avoid prop explosion.
Document precedence rules when child-level disables differ from group-level.
Developer Notes
Props Reference
Complete reference for all props available on Button, ButtonGroup component(s), including type definitions, default values, and usage examples.
Button
Core Props
type
'button' | 'link'default: 'button'
text
stringdefault: ''
children
React.ReactElement | React.JSX.Element | React.ReactNode | stringdefault: ''
href
stringdefault: ''
target
'_self' | '_blank' | '_parent' | '_top'default: '_self'
onClick
(e?: React.MouseEvent<HTMLButtonElement | HTMLAnchorElement, MouseEvent>) => void | Promise<void>default: undefined
Visual Props
variant
'default' | 'primary' | 'secondary' | 'success' | 'error' | 'warning'default: 'default'
appearance
'solid' | 'outline' | 'outline'-dashed | no-'outline' | 'glowing'default: 'solid'
transparent
booleandefault: false
size
'xsm' | 'sm' | 'md' | 'lg' | 'xlg'default: 'md'
radius
'none' | 'sm' | 'md' | 'lg' | 'full'default: 'md'
spinnerType
'default' | 'duo' | 'gradient' | 'pulse' | 'pulse-duo'default: 'default'
State Props
disabled
booleandefault: false
isLoading
booleandefault: false
Advanced Props
icon
className
stringdefault: ''
style
React.CSSPropertiesdefault: {}
ButtonGroup
Core Props
children
React.ReactElement<IButton> | React.ReactElement<IButton>[]
State Props
disabled
booleandefault: false
Visual Props
variant
'default'| 'primary' | 'secondary' | 'success' | 'error' | 'warning'default: 'default'
size
'xsm' | 'sm' | 'md' | 'lg' | 'xlg'default: 'md'
radius
'none' | 'sm' | 'md' | 'lg' | 'full'default: 'md'
align
'vertical' | 'horizontal'default: 'horizontal'
Advanced Props
className
stringdefault: ''
style
React.CSSPropertiesdefault: {}

