-
Notifications
You must be signed in to change notification settings - Fork 326
Docs update to classes #1682
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
Docs update to classes #1682
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,28 @@ In Tailwind CSS, you can make any utility class important by adding a `!` charac | |
|
|
||
| ## Overwriting Specific Classes | ||
|
|
||
| While the `class` prop can be used for most components, some components with a complex structure may require multiple props. For instance, let's consider [the Banner component](https://next.flowbite-svelte.com/docs/components/banner#component-data) has two relevant props: `class` for `div` and `classInner` for `innerClass`. To overwrite the `div`, you can use the `classDiv` prop: | ||
| While the `class` prop can be used for most components, some components with a complex structure may require multiple props. | ||
|
|
||
| For instance, let's consider [the Banner component](https://next.flowbite-svelte.com/docs/components/banner#component-data) has two relevant props: `class` for `div` and `classInner` for `innerClass`. To overwrite the `div`, you can use the `classDiv` prop: | ||
|
|
||
| ```svelte example class="flex flex-col relative" | ||
| <script> | ||
| import { Banner, Skeleton, ImagePlaceholder } from "flowbite-svelte"; | ||
| </script> | ||
|
|
||
| <Skeleton class="py-4" /> | ||
| <ImagePlaceholder class="py-4" /> | ||
|
|
||
| <Banner id="default-banner" type="bottom" class="border-green-600 bg-green-700 dark:border-green-400 dark:bg-green-500" innerClass="text-white"> | ||
| <p class="flex items-center text-sm font-normal">Overwriting divClass and innerClass</p> | ||
| </Banner> | ||
| ``` | ||
|
Comment on lines
+47
to
+58
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. π οΈ Refactor suggestion Example uses wrong / deprecated prop names The snippet still shows -<Banner id="default-banner" type="bottom" class="border-green-600 bg-green-700 dark:border-green-400 dark:bg-green-500" innerClass="text-white">
+<Banner
+ id="default-banner"
+ type="bottom"
+ class="border-green-600 bg-green-700 dark:border-green-400 dark:bg-green-500"
+ innerClass="text-white"
+>
π€ Prompt for AI Agents |
||
|
|
||
| You can observe the background color change to green. | ||
|
|
||
| ### New way of customization | ||
|
|
||
| Instead of intrducing multiple props for component's internal element classes new prop `classes` has been introduced: an object of internal element names and desired new classes. The above example will therefore change to: | ||
|
|
||
| ```svelte example class="flex flex-col relative" | ||
| <script> | ||
|
|
@@ -50,12 +71,12 @@ While the `class` prop can be used for most components, some components with a c | |
| <Skeleton class="py-4" /> | ||
| <ImagePlaceholder class="py-4" /> | ||
|
|
||
| <Banner id="default-banner" type="bottom" class="dark:border-green-400 dark:bg-green-500"> | ||
| <p class="flex items-center text-sm font-normal text-gray-500 dark:text-white">Overwriting divClass and innerClass</p> | ||
| <Banner id="default-banner" type="bottom" class="border-green-600 bg-green-700 dark:border-green-400 dark:bg-green-500" classes={{ insideDiv:"text-white" }}> | ||
| <p class="flex items-center text-sm font-normal">Overwriting divClass and innerClass</p> | ||
| </Banner> | ||
| ``` | ||
|
|
||
| You can test this by switching to dark mode and observing the background color change to green. | ||
| The `classes` prop becomes the default way of customization and the multiple props mentioned above are marked as deprecated. | ||
|
|
||
| We hope these instructions help you confidently customize component classes. Feel free to reach out if you have any further questions! | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
π οΈ Refactor suggestion
Prop-name inconsistencies will confuse readers
You mix three different identifiers for the same Banner prop:
classInner,innerClass, andclassDiv. Please standardise on the actual API names (per current source itβsinnerClassandclass) or readers will waste time hunting for the correct prop.π Committable suggestion
π€ Prompt for AI Agents