import plugin from 'tailwindcss/plugin'; import svgToDataUri from 'mini-svg-data-uri'; export default plugin(({ addComponents, theme }) => { // Radio addComponents({ '.radio[type="radio"]': { 'flex-shrink': '0', 'appearance': 'none', 'box-shadow': 'none', 'background-color': 'var(--tw-light-light)', '.dark &': { 'background-color': 'var(--tw-coal-500)', }, 'border-radius': '50%', 'height': theme('custom.components.radio.DEFAULT.size'), 'width': theme('custom.components.radio.DEFAULT.size'), 'border': '1px solid var(--tw-gray-300)', 'background-repeat': 'no-repeat', 'background-size': 'contain', 'background-position': 'center', '&:checked, &[aria-checked="true"]': { 'background-color': 'var(--tw-primary)', 'border': '1px solid var(--tw-primary)', 'background-image': `url("${svgToDataUri('')}")`, }, '&:focus-visible': { 'outline': 'none', 'box-shadow': 'none' }, '&:focus': { 'border-color': 'var(--tw-primary)', 'box-shadow': 'var(--tw-input-focus-box-shadow)', 'color': 'var(--tw-gray-700)', '&::placeholder': { 'color': 'var(--tw-gray-600)', }, }, '&:active': { 'color': 'var(--tw-gray-700)', '&::placeholder': { 'color': 'var(--tw-gray-600)', }, 'box-shadow': 'none', }, '&:disabled': { 'cursor': 'not-allowed', 'background-color': 'var(--tw-gray-200)', 'border': '1px solid var(--tw-gray-300)', '&:checked, &[aria-checked="true"]': { 'background-color': 'var(--tw-primary-clarity)', 'border': '0', }, }, }, '.radio-sm[type="radio"]': { 'height': theme('custom.components.radio.sm.size'), 'width': theme('custom.components.radio.sm.size'), '&:checked, &[aria-checked="true"]': { 'background-image': `url("${svgToDataUri('')}")`, }, }, '.radio-lg[type="radio"]': { 'height': theme('custom.components.radio.lg.size'), 'width': theme('custom.components.radio.lg.size'), '&:checked, &[aria-checked="true"]': { 'background-image': `url("${svgToDataUri('')}")`, }, }, }); // Group & labels addComponents({ '.radio-group': { 'display': 'flex', 'align-items': 'center', 'gap': '0.4rem', }, '.radio-label': { 'color': 'var(--tw-gray-800)', 'font-weight': theme('fontWeight.medium'), 'font-size': theme('fontSize.2sm'), 'line-height': theme('fontSize.2sm.1.lineHeight'), }, '.radio-label-lg': { 'font-size': theme('fontSize.sm'), 'line-height': theme('fontSize.sm.1.lineHeight'), }, }); });