Patterns · Settings
Info box
A settings-only tinted callout in four tones (information / success / warning / error), optionally dismissible — a bespoke component, not Ant Alert.
Examples
Tone
Four tones — bespoke tinted callouts (not Ant Alert); the warning one is dismissible
<!-- Paste-and-run: save as .html and open in a browser. No build step.
<aha-info-box> is the SAME shared custom element React and Vue consume — here in its native form.
Theming comes only from the --aha-* tokens in tokens.css. Bespoke, NOT Ant Alert. The dismiss ✕
fades the box out and emits `dismiss` — the host owns any "don't show again" state. -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/ahaslides-product/ahaslides-design@master/lib/tokens.css">
<script type="module">
import 'https://cdn.jsdelivr.net/gh/ahaslides-product/ahaslides-design@master/lib/aha-info-box.js'; // registers <aha-info-box>
</script>
<div style="display:flex; flex-direction:column; gap:8px; max-width:420px">
<aha-info-box variant="information">Points are awarded for correct answers only.</aha-info-box>
<aha-info-box variant="success">Your changes are saved.</aha-info-box>
<aha-info-box variant="warning" id="warn" dismissible>Turning this off clears saved responses.</aha-info-box>
<aha-info-box variant="error">This slide type needs at least two options.</aha-info-box>
</div>
<script>
document.getElementById('warn').addEventListener('dismiss', () => console.log('dismissed'));
</script>
import '@ahaslides-product/design/aha-info-box'; // registers <aha-info-box>
import { useRef, useEffect } from 'react';
// React 18 needs a thin wrapper; React 19 can use <aha-info-box> directly.
// Bespoke callout (NOT Ant Alert); onDismiss fires after the box fades out.
function AhaInfoBox({ variant, icon, dismissible, onDismiss, children }) {
const ref = useRef();
useEffect(() => {
const el = ref.current;
const h = () => onDismiss?.(); // composed CustomEvent
el.addEventListener('dismiss', h);
return () => el.removeEventListener('dismiss', h);
}, [onDismiss]);
return (
<aha-info-box
ref={ref}
{...(variant ? { variant } : {})}
{...(icon ? { icon } : {})}
{...(dismissible ? { dismissible: '' } : {})}
>{children}</aha-info-box>
);
}
// usage
<AhaInfoBox variant="warning" dismissible onDismiss={() => setSeen(true)}>
Turning this off clears saved responses.
</AhaInfoBox>
// main.ts — register the element + mark aha-* as custom elements
import '@ahaslides-product/design/aha-info-box'; // registers <aha-info-box>
app.config.compilerOptions.isCustomElement = (tag) => tag.startsWith('aha-');
// Component.vue
<script setup>
import { ref } from 'vue';
const seen = ref(false);
</script>
<template>
<!-- bespoke callout (NOT Ant Alert); @dismiss fires after the box fades out -->
<aha-info-box
v-if="!seen"
variant="warning"
dismissible
@dismiss="seen = true"
>Turning this off clears saved responses.</aha-info-box>
</template>
API
| Prop | Type | Default | Notes |
|---|---|---|---|
variant | information | success | warning | error | information | The tone — sets fill, border and leading glyph |
icon | string | — | Override the tone's default glyph with a named DS icon |
dismissible | boolean | false | Show the ✕ dismiss control |
dismiss | CustomEvent | — | Composed event after the box fades out |
Install
# .npmrc — once: point the @ahaslides-product scope at GitHub Packages
@ahaslides-product:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN} # a GitHub token with read:packages
npm i @ahaslides-product/design
import '@ahaslides-product/design/tokens.css'; // once, at the app root
import '@ahaslides-product/design/aha-info-box'; // registers <aha-info-box>
Agent feed for this component (absolute, fetchable anywhere): info-box.agent.json · info-box.md · info-box.llms.txt
When to use
When to use
- Info box — a settings-panel callout explaining a state or a consequence in place
- Help text — a one-line must-see consequence attached to a single setting (≤90 chars) — not a box
- Tooltip — secondary what/why/how elaboration on a ? glyph
Bespoke, NOT Ant Alert — Alert renders outside the DS theme. Keep callouts rare: most explanation is a ? tooltip or nothing (SETTINGS-28). Use error/warning for a consequence, not decoration.
Surfaces
editor settings
Spec
Box padding 12 · radius 8 · 1px tinted border + tinted fill per tone · Information #F4F8FF fill · #BFD2FF border · #9BB3E9 glyph (system-info) · Success #D8FAEF fill · #16C49A border/glyph (system-check-circle) · Warning #FFF5F0 fill · #FF7747 border/glyph (system-warning-circle) · Error #FFE3E9 fill · #FF4081 border/glyph — Radical Pink, NOT red (system-x-circle) · Dismiss optional ✕ (system-x); fades out on a persistent node, emits `dismiss` · Text Plus Jakarta 14/21 #1A1A1A