ActionBar
The bottom bar of a work tool such as a till, a kiosk or a picking tool: equal tiles with an icon (20 px), a label cut with the full text in title, and a key hint (a left-to-right Kbd, such as F2, hidden on a touch screen). The bar only shows the hints: the app binds the keys. Tiles are 56 px high (64 px in data-density="touch"); when any item has a keyHint, all tiles are 72 px high on a mouse so the key keeps clear of the edge and the label (on a touch screen the hints are hidden and the heights above apply). tone: "danger" gives red text and border; disabled keeps the tile in its place. group: "end" puts an item after a separator at the end side, and it never goes into the overflow. When a tile would be narrower than 5rem, the last main items move into a “More” menu (label and key hint per row). It is a nav named by label; Tab moves between the tiles. No items: nothing renders. The order follows the reading direction. For buttons in a row use ButtonGroup; for one keyboard key use Kbd.
import { ActionBar, type ActionBarItem } from "@percentsa/ui";Examples
Choose an action.
Code
export function ActionBarExample() {
const t = useT();
const [last, setLast] = useState<string>();
const pick = (name: string) => () => setLast(name);
const items: ActionBarItem[] = [
{ id: "help", label: t("Help", "مساعدة"), icon: <CircleHelp aria-hidden />, keyHint: "F1", onSelect: pick(t("Help", "مساعدة")) },
{ id: "orders", label: t("Orders", "الطلبات"), icon: <ReceiptText aria-hidden />, keyHint: "F2", onSelect: pick(t("Orders", "الطلبات")) },
{ id: "holds", label: t("Held carts", "السلال المعلقة"), icon: <Pause aria-hidden />, keyHint: "F7", onSelect: pick(t("Held carts", "السلال المعلقة")) },
{ id: "cash", label: t("Cash", "النقد"), icon: <Wallet aria-hidden />, keyHint: "F8", onSelect: pick(t("Cash", "النقد")) },
{ id: "history", label: t("History", "السجل"), icon: <Clock aria-hidden />, keyHint: "F9", disabled: true, onSelect: pick(t("History", "السجل")) },
{ id: "close", label: t("Close shift", "إغلاق الوردية"), icon: <Power aria-hidden />, tone: "danger", group: "end", onSelect: pick(t("Close shift", "إغلاق الوردية")) },
];
return (
<Stack gap={3} className="w-full">
<ActionBar label={t("Till actions", "إجراءات الصندوق")} items={items} />
<Text size="sm" tone="muted" aria-live="polite">
{last ? t(`Chosen: ${last}`, `المختار: ${last}`) : t("Choose an action.", "اختر إجراءً.")}
</Text>
</Stack>
);
}
/** In a narrow box a tile would be under 5rem wide: the last main items move into the More menu; the end item stays. */Code
export function ActionBarOverflowExample() {
const t = useT();
const items: ActionBarItem[] = [
{ id: "help", label: t("Help", "مساعدة"), icon: <CircleHelp aria-hidden />, keyHint: "F1", onSelect: () => {} },
{ id: "orders", label: t("Orders", "الطلبات"), icon: <ReceiptText aria-hidden />, keyHint: "F2", onSelect: () => {} },
{ id: "holds", label: t("Held carts", "السلال المعلقة"), icon: <Pause aria-hidden />, keyHint: "F7", onSelect: () => {} },
{ id: "cash", label: t("Cash", "النقد"), icon: <Wallet aria-hidden />, keyHint: "F8", onSelect: () => {} },
{ id: "close", label: t("Close shift", "إغلاق الوردية"), icon: <Power aria-hidden />, tone: "danger", group: "end", onSelect: () => {} },
];
return (
<div className="w-full max-w-sm">
<ActionBar label={t("Till actions", "إجراءات الصندوق")} items={items} />
</div>
);
}
/** A cash keypad for an amount: the draft is the text of a MoneyInput; a hardware keyboard works while the focus is on the page or in the keypad. */