Composables
Abbreviation Element
Style abbreviation elements with configurable cursor and text decoration using the useAbbrElement composable.
Overview
The useAbbrElement composable styles abbr[title] elements with a help cursor and dotted underline, making it clear to users that a tooltip is available on hover.
useAbbrElement
function useAbbrElement(
s: Styleframe,
options?: WithThemes<AbbrElementConfig>
): AbbrElementResult
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useAbbrElement } from '@styleframe/theme';
const s = styleframe();
const { abbrCursor, abbrTextDecoration } = useAbbrElement(s);
export default s;
styleframe/index.css
:root {
--abbr--cursor: help;
--abbr--text-decoration: underline dotted;
}
abbr[title] {
cursor: var(--abbr--cursor);
text-decoration-skip-ink: none;
text-decoration: var(--abbr--text-decoration);
}
Default Values
| Option | Default | Variable | Export |
|---|---|---|---|
cursor | "help" | --abbr--cursor | abbrCursor |
textDecoration | "underline dotted" | --abbr--text-decoration | abbrTextDecoration |
Custom Values
styleframe.config.ts
import { styleframe } from 'styleframe';
import { useAbbrElement } from '@styleframe/theme';
const s = styleframe();
const { abbrCursor, abbrTextDecoration } = useAbbrElement(s, {
cursor: 'pointer',
textDecoration: 'underline dashed',
});
export default s;
styleframe/index.css
:root {
--abbr--cursor: pointer;
--abbr--text-decoration: underline dashed;
}
abbr[title] {
cursor: var(--abbr--cursor);
text-decoration-skip-ink: none;
text-decoration: var(--abbr--text-decoration);
}
Best Practices
- Keep the help cursor: The default
helpcursor signals to users that additional information is available on hover. - Use dotted underlines: The
underline dotteddecoration distinguishes abbreviations from regular links while indicating interactivity. - Always include a title attribute: The composable targets
abbr[title], so elements without atitleattribute are unaffected.