@@ -1,21 +1,45 @@
1-import type { Color, ContainerNode } from "@cel-tui/types";
1+import type { ContainerNode, StyleProps } from "@cel-tui/types";
22 import { HStack, Text } from "@cel-tui/core";
33
4-/** Props for the {@link Button} component. */
5-export interface ButtonProps {
4+/**
5+ * Props for the {@link Button} component.
6+ *
7+ * Extends {@link StyleProps} — all style props (`fgColor`, `bgColor`,
8+ * `bold`, `italic`, `underline`) are set on the container and inherited
9+ * by the label text. This enables `focusStyle` to override them when
10+ * the button is focused.
11+ */
12+export interface ButtonProps extends StyleProps {
613 /** Called on mouse click or Enter when focused. */
714 onClick: () => void;
8- /** Render the label in bold. */
9- bold?: boolean;
10- /** Label text color. */
11- fgColor?: Color;
12- /** Label background color. */
13- bgColor?: Color;
1415 /**
1516 * Whether the button participates in focus traversal.
1617 * @default true
1718 */
1819 focusable?: boolean;
20+ /**
21+ * Whether this button is currently focused (controlled mode).
22+ * When provided, the app owns focus state and must update it
23+ * via {@link onFocus}/{@link onBlur}.
24+ */
25+ focused?: boolean;
26+ /** Called when the button receives focus. */
27+ onFocus?: () => void;
28+ /** Called when the button loses focus. */
29+ onBlur?: () => void;
30+ /**
31+ * Style overrides applied when focused. Overridden values
32+ * participate in inheritance — the label text sees the
33+ * focused styles as its defaults.
34+ */
35+ focusStyle?: StyleProps;
36+ /**
37+ * Key event handler. Receives keys that bubble up to this button.
38+ * Return `false` to keep bubbling.
39+ */
40+ onKeyPress?: (key: string) => boolean | void;
41+ /** Internal padding in cells. */
42+ padding?: { x?: number; y?: number };
1943 }
2044
2145 /**
@@ -25,20 +49,30 @@ export interface ButtonProps {
2549 * a styled `Text` node. Focusable by default — reachable via Tab and
2650 * activated with Enter.
2751 *
52+ * Style props are set on the container, not the text — this means
53+ * `bgColor` fills the button rect and `focusStyle` can override
54+ * any style when focused.
55+ *
2856 * @param label - Button text.
29- * @param props - Click handler and styling.
57+ * @param props - Click handler, styling, and focus configuration.
3058 * @returns A clickable container node.
3159 *
3260 * @example
61+ * // Basic styled button
3362 * Button("[Send]", { onClick: handleSend, bold: true, fgColor: "cyan" })
3463 *
3564 * @example
65+ * // Button with focus style (keyboard navigation)
66+ * Button("[OK]", {
67+ * onClick: handleOk,
68+ * bgColor: "brightBlack",
69+ * focusStyle: { bgColor: "green", fgColor: "black" },
70+ * })
71+ *
72+ * @example
3673 * // Mouse-only button (not in Tab order)
3774 * Button("✕", { onClick: handleClose, focusable: false })
3875 */
3976 export function Button(label: string, props: ButtonProps): ContainerNode {
40- const { onClick, bold, fgColor, bgColor, focusable } = props;
41- return HStack({ onClick, focusable }, [
42- Text(label, { bold, fgColor, bgColor }),
43- ]);
77+ return HStack(props, [Text(label)]);
4478 }