Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature]: Provide a tailwind preset #1057

Open
BarakChamo opened this issue May 22, 2024 · 0 comments
Open

[Feature]: Provide a tailwind preset #1057

BarakChamo opened this issue May 22, 2024 · 0 comments
Labels
Type: Docs Indicates that the documentation is affected. Either add or correct docs. Type: Feature New feature for existing component Type: Theming Indicates that the styling is affected.

Comments

@BarakChamo
Copy link

What problem does this feature solve?

The current setup process is quite messy, having to copy and paste a large tailwind configuration and merge it into existing setups that may clash with other libraries.

Having now integrated tremor with a shadcn/ui project using tailwind presets, I think it would be helpful to provide a default preset and offer documentation on how to overwrite / customize colors.

This will also allow to resolve issues with content when using tremor in monorepos with no hoisting (like when using bun).

This is the preset that works for me with the latest version of tremor:

Tailwind preset

import { dirname } from 'node:path'
import headlessUITW from '@headlessui/tailwindcss'
import tailwindForms from '@tailwindcss/forms'
import type { Config } from 'tailwindcss'
import colors from 'tailwindcss/colors'

// absolute path to fix monorepo content mapping
const contentPath = `${dirname(require.resolve('@tremor/react/package.json'))}/**/*.{js,ts,jsx,tsx}`

const config: Config = {
	content: [contentPath],
	theme: {
		extend: {
                    ...
		},
	},
	safelist: [...],
	plugins: [headlessUiTwPlugin, tailwindFormsPlugin],
}

export default config

Using the preset

This is how I'm using this preset alongside other custom presets:

import { default as uiPreset } from '@this/ui/presets/ui'
import { default as chartsPreset } from '@this/ui/presets/tremor'

const config: Config = {
	darkMode: 'media',
	// TW overwrites content, so must be listed again
	content: [...(uiPreset.content as string[]), ...(chartsPreset.content as string[]), './src/**/*.{js,ts,jsx,tsx}'],
	presets: [uiPreset, chartsPreset],
}

Folks can then extend as they wish since extends are merged, but without having to copy all the boilerplate.

What does the proposed API look like?

No response

@severinlandolt severinlandolt added Type: Feature New feature for existing component Type: Docs Indicates that the documentation is affected. Either add or correct docs. Type: Theming Indicates that the styling is affected. labels May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Docs Indicates that the documentation is affected. Either add or correct docs. Type: Feature New feature for existing component Type: Theming Indicates that the styling is affected.
Projects
None yet
Development

No branches or pull requests

2 participants