Loading component…
Loading component…
A square button that is only an icon
To reuse this local React demo, copy all files from the Code tab into the same folder, then import IconButton from ./icon-button.
import { useState } from "react";
import { FilterHorizontalIcon, PinIcon, PlusSignIcon } from "@hugeicons/core-free-icons";
import { IconButton } from "@/components/ui/icon-button";
export function RunsToolbar({ onNew }: { onNew: () => void }) {
const [pinned, setPinned] = useState(false);
return (
<div style={{ display: "flex", gap: 6 }}>
<IconButton variant="secondary" icon={FilterHorizontalIcon} label="Filter" />
<IconButton
variant="secondary"
icon={PinIcon}
label="Pinned runs only"
pressed={pinned}
onClick={() => setPinned((p) => !p)}
/>
<IconButton variant="primary" icon={PlusSignIcon} label="New run" onClick={onNew} />
</div>
);
}| Name | Type | Default | Description |
|---|---|---|---|
| icon | ReactNode \| HugeIcon | The glyph – an inline SVG or image, or a Hugeicons icon object, which is drawn inline at a 1.75 stroke. It takes the button's color | |
| label | string | Required. What it does – the accessible name (aria-label) and the tooltip | |
| variant | "ghost" \| "secondary" \| "primary" | "ghost" | ghost: just the icon, a soft wash on hover · secondary: white with a 1px edge, for toolbars · primary: the dark gradient of the primary Button |
| size | "sm" \| "md" | "md" | 32 × 32 with a 16px icon, or 40 × 40 with an 18px icon – the heights of the Button |
| pressed | boolean | Makes it a toggle: sets aria-pressed and keeps the gray layer while true. Leave it out for a plain button | |
| title | string | label | The tooltip; pass "" to leave it out, e.g. when a custom tooltip wraps the button |
| ...button props | ComponentProps<"button"> | onClick, disabled, type, aria-expanded, ref and the rest go to the real <button> |
Touch screens keep the look and get an invisible ring around it that takes the tap – the small size grows to 42 × 42
Dark mode built in: switches when an ancestor (usually <html>) has the class dark or data-theme="dark"
@import "tailwindcss"; in your main CSS file.