|
| 1 | +--- |
| 2 | +title: Labels and icons |
| 3 | +sidebar: |
| 4 | + order: 2 |
| 5 | +--- |
| 6 | + |
| 7 | +import { LinkCard, LinkButton, Code, Card } from '@astrojs/starlight/components' |
| 8 | + |
| 9 | +import Npm from '@/components/npm.astro'; |
| 10 | + |
| 11 | +import Icons from './_icons.astro'; |
| 12 | +import iconsCode from './_icons.svelte?raw'; |
| 13 | + |
| 14 | +## Translation |
| 15 | + |
| 16 | +One of the mandatory components of a form is `translate`. You can see its use in various places in the form (various buttons and labels). |
| 17 | + |
| 18 | +Translations are imported from `@sjsf/form/translations/{locale}`, currently supported locales: |
| 19 | + |
| 20 | +- `en` |
| 21 | +- `ru` |
| 22 | + |
| 23 | +<LinkCard title="Translation API reference" href="../../api-reference/translation/" /> |
| 24 | + |
| 25 | +## Icons |
| 26 | + |
| 27 | +Text is good, but you can do better by adding icons! |
| 28 | + |
| 29 | +<Code code={iconsCode} lang='svelte' /> |
| 30 | + |
| 31 | +<Card> |
| 32 | + <Icons /> |
| 33 | +</Card> |
| 34 | + |
| 35 | + |
| 36 | +<LinkCard title="Icons API reference" href="../../api-reference/icons/" /> |
| 37 | + |
| 38 | +There are also ready-made sets of icons for control buttons. |
| 39 | + |
| 40 | +### Lucide icons |
| 41 | + |
| 42 | +Installation: |
| 43 | + |
| 44 | +<Npm pkg="@sjsf/lucide-icons" /> |
| 45 | + |
| 46 | +Usage: |
| 47 | + |
| 48 | +```svelte |
| 49 | +<script lang="ts"> |
| 50 | + import { Form } from '@sjsf/form'; |
| 51 | + import { icons } from '@sjsf/lucide-icons'; |
| 52 | +</script> |
| 53 | +
|
| 54 | +<Form {icons} /> |
| 55 | +``` |
| 56 | + |
| 57 | +<LinkButton |
| 58 | + href="https://x0k.github.io/svelte-jsonschema-form/playground/?sample=Arrays&theme=daisy&icons=lucide&vevent=0&vafter=0" |
| 59 | + variant="secondary" |
| 60 | + icon="external" |
| 61 | + iconPlacement="end" |
| 62 | + target="_blank" |
| 63 | +> |
| 64 | + Playground |
| 65 | +</LinkButton> |
| 66 | + |
| 67 | +### Flowbite icons |
| 68 | + |
| 69 | +Installation: |
| 70 | + |
| 71 | +<Npm pkg="@sjsf/flowbite-icons" /> |
| 72 | + |
| 73 | +Add icons content to a tailwindcss config: |
| 74 | + |
| 75 | +```typescript |
| 76 | +import { FLOWBITE_ICONS_CONTENT } from '@sjsf/flowbite-icons/preset' |
| 77 | + |
| 78 | +/** @type {import('tailwindcss').Config} */ |
| 79 | +export default { |
| 80 | + content: ['./src/**/*.{html,js,svelte,ts}', FLOWBITE_ICONS_CONTENT], |
| 81 | +} |
| 82 | +``` |
| 83 | + |
| 84 | +Usage: |
| 85 | + |
| 86 | +```svelte |
| 87 | +<script lang="ts"> |
| 88 | + import { Form } from '@sjsf/form'; |
| 89 | + import { icons } from '@sjsf/flowbite-icons'; |
| 90 | +</script> |
| 91 | +
|
| 92 | +<Form {icons} /> |
| 93 | +``` |
| 94 | + |
| 95 | +<LinkButton |
| 96 | + href="https://x0k.github.io/svelte-jsonschema-form/playground/?sample=Arrays&theme=flowbite&icons=flowbite&vevent=0&vafter=0" |
| 97 | + variant="secondary" |
| 98 | + icon="external" |
| 99 | + iconPlacement="end" |
| 100 | + target="_blank" |
| 101 | +> |
| 102 | + Playground |
| 103 | +</LinkButton> |
0 commit comments