Anchor
Usage
Decoration
With Button Variant
Properties
Styles
Tailwind utilities
Add the following utilities css
to your tailwind.config.js
file:
import { PluginAPI, type Config } from "tailwindcss/types/config";
import plugin from "tailwindcss/plugin";
export default {
theme: {
extend: {}
},
plugins: [
require("tailwindcss-animate"),
plugin(({ addBase, addUtilities }: PluginAPI) => {
addBase({});
addUtilities({
".underline-hover": {
position: "relative",
touchAction: "manipulation",
"&::after": {
content: '""',
position: "absolute",
bottom: "var(--underline-offset, 2px)",
backgroundColor: "currentColor",
height: "1px"
},
"@media (hover: hover)": {
"&::after": {
left: "0",
width: "100%",
transform: "scaleX(0)",
transformOrigin: "right center",
transition: "transform .45s cubic-bezier(0.86, 0, 0.07, 1)"
},
"&:hover": {
"&::after": {
transform: "scaleX(1)",
transformOrigin: "left center",
animation: "none"
}
}
},
"@media not all and (hover: hover)": {
"&::after": {
width: "0"
},
"&:hover": {
"&::after": {
animation: "underlinehover 0.75s cubic-bezier(0.86, 0, 0.07, 1)"
}
}
}
}
});
})
]
} satisfies Config;
Globals CSS
Remember to add keyframes styles to your global.css file.
API References
Styles API
Styles API | Type | Default | Annotation |
---|---|---|---|
unstyled? | boolean | false | if true , all default styles will be removed |
underline? | "always" | "hover" | "never" | never | |
role? | "anchor" | AriaRole | undefined | if role="anchor" , add blue color style |