DaisyUI Components
This page shows how to use daisyUI component classes as astro-smart-links class names, so links reuse the component library’s styles. Every preview is the real output of that config (examples without an icon disable the default ↗ icon with content: null).
Badge Links
Section titled “Badge Links”Render links as daisyUI badges:
Badge Links
import { smartLinks } from 'astro-smart-links';
smartLinks({ internalLinkClass: 'badge badge-primary', externalLinkClass: 'badge badge-secondary', brokenLinkClass: 'badge badge-error', content: null,}),Button Links
Section titled “Button Links”Render links as daisyUI buttons:
Button Links
import { smartLinks } from 'astro-smart-links';
smartLinks({ internalLinkClass: 'btn btn-primary btn-sm', externalLinkClass: 'btn btn-secondary btn-sm', brokenLinkClass: 'btn btn-error btn-sm', content: null,}),Link Styles
Section titled “Link Styles”Use daisyUI’s link component classes:
Link Styles
import { smartLinks } from 'astro-smart-links';
smartLinks({ internalLinkClass: 'link link-primary', externalLinkClass: 'link link-secondary', brokenLinkClass: 'link link-error', content: null,}),Card Links
Section titled “Card Links”Render the link itself as a card:
Card Links
import { smartLinks } from 'astro-smart-links';
smartLinks({ internalLinkClass: 'card w-full max-w-sm bg-base-100 p-4 shadow-xl hover:shadow-2xl transition-shadow duration-300 text-primary font-semibold', externalLinkClass: 'card w-full max-w-sm bg-base-100 p-4 shadow-xl hover:shadow-2xl transition-shadow duration-300 text-secondary font-semibold', brokenLinkClass: 'card w-full max-w-sm bg-base-100 p-4 shadow-xl text-error font-semibold line-through opacity-75 cursor-not-allowed', content: null,}),Tooltip Links
Section titled “Tooltip Links”Wrap links in daisyUI tooltips with wrapperTemplate and apply the link classes with meta.className:
Tooltip Links
import { smartLinks } from 'astro-smart-links';
smartLinks({ internalLinkClass: 'link link-hover link-primary', externalLinkClass: 'link link-hover link-secondary', brokenLinkClass: 'link link-hover link-error', wrapperTemplate: (node, type, meta) => { const variants = { internal: { className: 'tooltip tooltip-primary', tip: 'Navigate to the about page' }, external: { className: 'tooltip tooltip-secondary', tip: 'Opens in a new tab' }, broken: { className: 'tooltip tooltip-error', tip: 'This link is broken' }, }; const { className, tip } = variants[type];
node.properties.className = [...(node.properties.className || []), meta.className];
return { type: 'element', tagName: 'div', properties: { className: [className], 'data-tip': tip }, children: [node], }; },}),Theme-Aware Links
Section titled “Theme-Aware Links”daisyUI colors come from theme variables, so links follow the active theme:
Theme-Aware Links
@plugin "daisyui" { themes: light --default, dark --prefersdark;}import { smartLinks } from 'astro-smart-links';
smartLinks({ internalLinkClass: 'link link-primary', externalLinkClass: 'link link-accent', brokenLinkClass: 'link link-error', content: null,}),Combined Components
Section titled “Combined Components”Combine several component classes, e.g. a button with a badge:
Combined Components
import { smartLinks } from 'astro-smart-links';import { h } from 'hastscript';
smartLinks({ internalLinkClass: 'btn btn-primary btn-sm gap-2', externalLinkClass: 'btn btn-secondary btn-sm gap-2', brokenLinkClass: 'btn btn-error btn-sm gap-2', wrapperTemplate: (node, type, meta) => { const labels = { internal: 'Internal', external: 'External', broken: 'Missing' };
node.children.push(h('span', { className: 'badge badge-sm' }, labels[type])); node.properties.className = [...(node.properties.className || []), meta.className];
return node; },}),Next Steps
Section titled “Next Steps”Keep exploring:
- Tailwind Styles - Define link styles with Tailwind utilities
- Advanced Features - Learn about
wrapperTemplateand custom transforms