Skip to content
← Close
Edit Close
Name
Also known as (comma separated)
Brief definition
Dismisses an interface element.
Notes
Tier
Core
Useful
Reference
Deleted
Controls schema (JSON array)
[ { "id": "label", "type": "text", "label": "Accessible name", "default": "Close" }, { "id": "size", "type": "select", "label": "Size", "default": "md", "options": [ "sm", "md", "lg" ] }, { "id": "bg", "type": "color", "label": "Hover colour", "default": "#241430", "presets": [ "#241430", "#A8E6C1", "#F5C2E0", "#BFD9F2", "#D9C8F0", "#E8A020" ] }, { "id": "radius", "type": "number", "label": "Corner radius", "default": 999, "min": 0, "max": 999, "step": 1 }, { "id": "disabled", "type": "toggle", "label": "Disabled", "default": false } ]
Templates (JSON object keyed by format)
{ "html": "<button type=\"button\" class=\"btn-close btn-close--{{size}}\" style=\"--bg:{{bg}};border-radius:{{radius}}px\" aria-label=\"{{label}}\"{{#if disabled}} disabled{{/if}}>\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M6 6l12 12M18 6L6 18\"/></svg>\n</button>\n<style>\n.btn-close {\n display: inline-flex; align-items: center; justify-content: center;\n border: none;\n background: transparent;\n color: #241430;\n cursor: pointer;\n padding: 8px;\n}\n.btn-close--sm { padding: 5px; }\n.btn-close--lg { padding: 11px; }\n.btn-close:hover:not(:disabled) { background: rgba(36,20,48,.1); color: var(--bg); }\n.btn-close:active:not(:disabled) { background: rgba(36,20,48,.18); }\n.btn-close:focus-visible { outline:2px solid #241430;outline-offset:2px; }\n.btn-close:disabled { opacity: .4; cursor: not-allowed; }\n</style>", "tailwind": "<button type=\"button\" class=\"inline-flex items-center justify-center border-none bg-transparent cursor-pointer text-[#241430] disabled:opacity-40 disabled:cursor-not-allowed hover:bg-black/10 active:bg-black/15 btn-close-tw btn-close-tw--{{size}}\" style=\"border-radius:{{radius}}px\" aria-label=\"{{label}}\"{{#if disabled}} disabled{{/if}}>\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"2\" stroke-linecap=\"round\" stroke-linejoin=\"round\" aria-hidden=\"true\" focusable=\"false\"><path d=\"M6 6l12 12M18 6L6 18\"/></svg>\n</button>\n<style>\n.btn-close-tw--sm { padding: 5px; }\n.btn-close-tw--md { padding: 8px; }\n.btn-close-tw--lg { padding: 11px; }\n.btn-close-tw:hover:not(:disabled) { color: {{bg}}; }\n.btn-close-tw:focus-visible { outline:2px solid #241430;outline-offset:2px; }\n</style>", "react": "export function CloseButton({\n label = \"{{label}}\",\n size = \"{{size}}\",\n bg = \"{{bg}}\",\n radius = {{radius}},\n disabled = {{disabled}},\n}) {\n const pad = size === \"sm\" ? 5 : size === \"lg\" ? 11 : 8;\n return (\n <button\n type=\"button\"\n aria-label={label}\n disabled={disabled}\n style={{\n display: \"inline-flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n padding: pad,\n borderRadius: radius,\n border: \"none\",\n background: \"transparent\",\n color: \"#241430\",\n cursor: disabled ? \"not-allowed\" : \"pointer\",\n opacity: disabled ? 0.4 : 1,\n }}\n onMouseOver={(e) => (e.currentTarget.style.color = bg)}\n onMouseOut={(e) => (e.currentTarget.style.color = \"#241430\")}\n >\n <svg width=\"18\" height=\"18\" viewBox=\"0 0 24 24\" fill=\"none\" stroke=\"currentColor\" strokeWidth=\"2\" strokeLinecap=\"round\" strokeLinejoin=\"round\" aria-hidden=\"true\">\n <path d=\"M6 6l12 12M18 6L6 18\" />\n </svg>\n </button>\n );\n}" }
Save
History