Icon Button
Icon buttons perform an action when clicked and visually represent the action through an icon, combining button functionality with visual symbolism.
import {IconButton} from "@qualcomm-ui/react/button"Accessibility Guidelines
Icon-only buttons rely on visual cues that screen readers cannot access. Use aria-label or aria-labelledby to give every icon-only button an accessible name so its purpose is clear to assistive technologies.
Examples
Variants
Buttons come in three variants: fill, outline, and ghost. Customize these with the variant property.
<IconButton aria-label="Navigate" icon={ExternalLink} variant="fill" />
<IconButton aria-label="Navigate" icon={ExternalLink} variant="outline" />
<IconButton aria-label="Navigate" icon={ExternalLink} variant="ghost" />
Emphasis
Control the visual emphasis with different colors: neutral, primary, and danger. Customize these with the emphasis prop.
<IconButton
aria-label="Navigate"
emphasis="neutral"
icon={ExternalLink}
variant="fill"
/>
<IconButton
aria-label="Navigate"
emphasis="primary"
icon={ExternalLink}
variant="fill"
/>
<IconButton
aria-label="Navigate"
emphasis="danger"
icon={ExternalLink}
variant="fill"
/>
Sizes and Icons
Customize size using the size property. QUI buttons come with built-in support for lucide-react icons.
<IconButton
aria-label="Navigate"
emphasis="primary"
icon={ExternalLink}
size="sm"
variant="fill"
/>
<IconButton
aria-label="Navigate"
emphasis="primary"
icon={ExternalLink}
size="md"
variant="fill"
/>
<IconButton
aria-label="Navigate"
emphasis="primary"
icon={ExternalLink}
size="lg"
variant="fill"
/>
Compact Density
Use the density prop to reduce the padding and height of the button. The options are default and compact.
<IconButton
aria-label="Navigate"
density="compact"
emphasis="primary"
icon={ExternalLink}
size="sm"
variant="fill"
/>
<IconButton
aria-label="Navigate"
density="compact"
emphasis="primary"
icon={ExternalLink}
size="md"
variant="fill"
/>
<IconButton
aria-label="Navigate"
density="compact"
emphasis="primary"
icon={ExternalLink}
size="lg"
variant="fill"
/>
Variant Combinations
<IconButton
aria-label="Search"
emphasis="neutral"
icon={Search}
variant="fill"
/>
<IconButton
aria-label="Search"
emphasis="neutral"
icon={Search}
variant="outline"
/>
<IconButton
aria-label="Search"
emphasis="neutral"
icon={Search}
variant="ghost"
/>
Contrast Colors
<div className="bg-persistent-black flex gap-6 p-4">
<IconButton
aria-label="Navigate"
emphasis="white-persistent"
icon={ExternalLink}
variant="fill"
/>
<IconButton
aria-label="Navigate"
emphasis="white-persistent"
icon={ExternalLink}
variant="outline"
/>
<IconButton
aria-label="Navigate"
emphasis="white-persistent"
icon={ExternalLink}
variant="ghost"
/>
</div>
API
<IconButton>
| Prop | Type | Default |
|---|---|---|
icon * lucide-react icon. Can be supplied as a
ReactElement for additional customization. | | LucideIcon | |
The density of the button. Governs padding and height. | | 'default' | 'default' |
Controls whether the component is interactive. When true, pointer/focus
events are blocked, and the component is visually dimmed. | boolean | false |
The style variant of the button. Governs colors. | | 'neutral' | 'neutral' |
Allows you to replace the component's HTML element with a different tag or component. Learn more | | ReactElement | |
The size of the component and its icons. | | 'sm' | 'md' |
The style variant of the button. Governs colors. | | 'fill' | 'fill' |
| LucideIcon
| ReactNode
ReactElement for additional customization.| 'default'
| 'compact'
booleantrue, pointer/focus
events are blocked, and the component is visually dimmed.| 'neutral'
| 'primary'
| 'danger'
| 'white-persistent'
| 'black-persistent'
| ReactElement
| ((
props: object,
) => ReactElement)
| 'sm'
| 'md'
| 'lg'
| 'fill'
| 'ghost'
| 'outline'
| Attribute / Property | Value |
|---|---|
className | 'qui-button__root' |
data-density | | 'default' |
data-disabled | |
data-part | 'root' |
data-scope | 'icon-button' |
data-size | | 'sm' |
data-variant | | 'fill' |
className'qui-button__root'data-density| 'default'
| 'compact'
data-disableddata-part'root'data-scope'icon-button'data-size| 'sm'
| 'md'
| 'lg'
data-variant| 'fill'
| 'ghost'
| 'outline'
<button>element by default.