From 83b968b310bc54bbbfa64228b43323fd888fa062 Mon Sep 17 00:00:00 2001 From: Vedant Agarwal <64523396+Vedant-29@users.noreply.github.com> Date: Wed, 2 Dec 2026 18:33:34 +0530 Subject: [PATCH] feat(@lucide/hono): add lucide package for Hono (#5069) * feat(@lucide/hono): add lucide package for Hono Adds `@lucide/hono`, a Lucide icon package for Hono JSX, modelled on `lucide-preact` and rendering through `@lucide/shared`. - Icon, createLucideIcon, LucideProvider and types built on `hono/jsx` - Supports class names from `hono/css` by merging with Hono's `cx()` - Tests ported from lucide-preact (identical snapshots) plus Hono specific tests - CI workflow, release matrix, labeler, issue templates and PR title scope - Docs pages, sidebar, framework select, package list and logos Closes #4928 * fix(@lucide/hono): address review feedback Remove the deprecated absoluteStrokeWidth prop, follow the aria-hidden rule from #5347, add build and integration jobs to the workflow, and add an integration fixture under integrations/lucide-hono. --- .github/ISSUE_TEMPLATE/02_bug_report.yml | 1 + .github/ISSUE_TEMPLATE/04_feature_request.yml | 1 + .github/labeler.yml | 6 + .github/workflows/lucide-hono.yml | 87 ++++++++++++ .github/workflows/release.yml | 1 + README.md | 1 + docs/.vitepress/data/packageData.json | 18 +++ docs/.vitepress/sidebar/hono.ts | 77 +++++++++++ docs/.vitepress/sidebar/index.ts | 2 + .../components/guide/FrameworkSelect.vue | 1 + .../home/HomePackagesSection.data.ts | 6 + docs/guide/hono/advanced/accessibility.md | 52 +++++++ docs/guide/hono/advanced/global-styling.md | 72 ++++++++++ docs/guide/hono/advanced/typescript.md | 111 +++++++++++++++ docs/guide/hono/advanced/with-lucide-lab.md | 30 +++++ docs/guide/hono/basics/color.md | 41 ++++++ docs/guide/hono/basics/sizing.md | 91 +++++++++++++ docs/guide/hono/basics/stroke-width.md | 48 +++++++ docs/guide/hono/getting-started.md | 89 ++++++++++++ docs/guide/hono/index.md | 53 ++++++++ docs/guide/index.md | 2 +- docs/guide/installation.md | 30 +++++ docs/images/package-logos/lucide-hono.svg | 28 ++++ docs/public/framework-logos/hono.svg | 10 ++ .../public/package-logos/dark/lucide-hono.svg | 21 +++ docs/public/package-logos/lucide-hono.svg | 24 ++++ integrations/lucide-hono/README.md | 20 +++ integrations/lucide-hono/vite/package.json | 25 ++++ .../lucide-hono/vite/src/IconShowcase.tsx | 30 +++++ integrations/lucide-hono/vite/src/app.tsx | 37 +++++ integrations/lucide-hono/vite/src/index.tsx | 3 + .../vite/tests/exports.node.test.ts | 38 ++++++ .../vite/tests/icons.browser.spec.tsx | 57 ++++++++ integrations/lucide-hono/vite/tsconfig.json | 21 +++ integrations/lucide-hono/vite/vite.config.ts | 26 ++++ package.json | 1 + packages/hono/README.md | 93 +++++++++++++ packages/hono/package.json | 66 +++++++++ packages/hono/rollup.config.mjs | 95 +++++++++++++ packages/hono/scripts/exportTemplate.mts | 36 +++++ packages/hono/src/Icon.tsx | 88 ++++++++++++ packages/hono/src/aliases/index.ts | 3 + packages/hono/src/context.tsx | 45 +++++++ packages/hono/src/createLucideIcon.tsx | 60 +++++++++ packages/hono/src/defaultAttributes.ts | 1 + packages/hono/src/icons/.gitkeep | 1 + packages/hono/src/lucide-hono.prefixed.ts | 7 + packages/hono/src/lucide-hono.suffixed.ts | 7 + packages/hono/src/lucide-hono.ts | 8 ++ packages/hono/src/types.ts | 27 ++++ packages/hono/src/utils.ts | 29 ++++ packages/hono/tests/Icon.spec.tsx | 127 ++++++++++++++++++ .../tests/__snapshots__/Icon.spec.tsx.snap | 34 +++++ .../tests/__snapshots__/context.spec.tsx.snap | 24 ++++ .../createLucideIcon.spec.tsx.snap | 88 ++++++++++++ .../__snapshots__/lucide-hono.spec.tsx.snap | 103 ++++++++++++++ packages/hono/tests/context.spec.tsx | 91 +++++++++++++ packages/hono/tests/createLucideIcon.spec.tsx | 70 ++++++++++ packages/hono/tests/hono.spec.tsx | 118 ++++++++++++++++ packages/hono/tests/lucide-hono.spec.tsx | 117 ++++++++++++++++ packages/hono/tests/setupVitest.js | 10 ++ packages/hono/tests/testIconNodes.ts | 22 +++ packages/hono/tests/utils/render.ts | 19 +++ packages/hono/tsconfig.json | 27 ++++ packages/hono/vitest.config.mts | 18 +++ pnpm-lock.yaml | 106 ++++++++++++--- pnpm-workspace.yaml | 1 + scripts/generatePullRequestTitle.mts | 1 + 68 files changed, 2685 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/lucide-hono.yml create mode 100644 docs/.vitepress/sidebar/hono.ts create mode 100644 docs/guide/hono/advanced/accessibility.md create mode 100644 docs/guide/hono/advanced/global-styling.md create mode 100644 docs/guide/hono/advanced/typescript.md create mode 100644 docs/guide/hono/advanced/with-lucide-lab.md create mode 100644 docs/guide/hono/basics/color.md create mode 100644 docs/guide/hono/basics/sizing.md create mode 100644 docs/guide/hono/basics/stroke-width.md create mode 100644 docs/guide/hono/getting-started.md create mode 100644 docs/guide/hono/index.md create mode 100644 docs/images/package-logos/lucide-hono.svg create mode 100644 docs/public/framework-logos/hono.svg create mode 100644 docs/public/package-logos/dark/lucide-hono.svg create mode 100644 docs/public/package-logos/lucide-hono.svg create mode 100644 integrations/lucide-hono/README.md create mode 100644 integrations/lucide-hono/vite/package.json create mode 100644 integrations/lucide-hono/vite/src/IconShowcase.tsx create mode 100644 integrations/lucide-hono/vite/src/app.tsx create mode 100644 integrations/lucide-hono/vite/src/index.tsx create mode 100644 integrations/lucide-hono/vite/tests/exports.node.test.ts create mode 100644 integrations/lucide-hono/vite/tests/icons.browser.spec.tsx create mode 100644 integrations/lucide-hono/vite/tsconfig.json create mode 100644 integrations/lucide-hono/vite/vite.config.ts create mode 100644 packages/hono/README.md create mode 100644 packages/hono/package.json create mode 100644 packages/hono/rollup.config.mjs create mode 100644 packages/hono/scripts/exportTemplate.mts create mode 100644 packages/hono/src/Icon.tsx create mode 100644 packages/hono/src/aliases/index.ts create mode 100644 packages/hono/src/context.tsx create mode 100644 packages/hono/src/createLucideIcon.tsx create mode 100644 packages/hono/src/defaultAttributes.ts create mode 100644 packages/hono/src/icons/.gitkeep create mode 100644 packages/hono/src/lucide-hono.prefixed.ts create mode 100644 packages/hono/src/lucide-hono.suffixed.ts create mode 100644 packages/hono/src/lucide-hono.ts create mode 100644 packages/hono/src/types.ts create mode 100644 packages/hono/src/utils.ts create mode 100644 packages/hono/tests/Icon.spec.tsx create mode 100644 packages/hono/tests/__snapshots__/Icon.spec.tsx.snap create mode 100644 packages/hono/tests/__snapshots__/context.spec.tsx.snap create mode 100644 packages/hono/tests/__snapshots__/createLucideIcon.spec.tsx.snap create mode 100644 packages/hono/tests/__snapshots__/lucide-hono.spec.tsx.snap create mode 100644 packages/hono/tests/context.spec.tsx create mode 100644 packages/hono/tests/createLucideIcon.spec.tsx create mode 100644 packages/hono/tests/hono.spec.tsx create mode 100644 packages/hono/tests/lucide-hono.spec.tsx create mode 100644 packages/hono/tests/setupVitest.js create mode 100644 packages/hono/tests/testIconNodes.ts create mode 100644 packages/hono/tests/utils/render.ts create mode 100644 packages/hono/tsconfig.json create mode 100644 packages/hono/vitest.config.mts diff --git a/.github/ISSUE_TEMPLATE/02_bug_report.yml b/.github/ISSUE_TEMPLATE/02_bug_report.yml index f5d8918bb..2bd5a6cd3 100644 --- a/.github/ISSUE_TEMPLATE/02_bug_report.yml +++ b/.github/ISSUE_TEMPLATE/02_bug_report.yml @@ -18,6 +18,7 @@ body: - label: '@lucide/svelte' - label: '@lucide/angular' - label: '@lucide/astro' + - label: '@lucide/hono' - label: lucide-react-native - label: lucide-preact - label: lucide-solid diff --git a/.github/ISSUE_TEMPLATE/04_feature_request.yml b/.github/ISSUE_TEMPLATE/04_feature_request.yml index 73d354ac8..8fffb3dd9 100644 --- a/.github/ISSUE_TEMPLATE/04_feature_request.yml +++ b/.github/ISSUE_TEMPLATE/04_feature_request.yml @@ -18,6 +18,7 @@ body: - label: '@lucide/svelte' - label: '@lucide/angular' - label: '@lucide/astro' + - label: '@lucide/hono' - label: lucide-react-native - label: lucide-preact - label: lucide-solid diff --git a/.github/labeler.yml b/.github/labeler.yml index b04b84b1e..2967bae10 100644 --- a/.github/labeler.yml +++ b/.github/labeler.yml @@ -91,6 +91,12 @@ - any-glob-to-any-file: - 'packages/astro/*' +# For changes in the Lucide hono package +🔥 hono package: + - changed-files: + - any-glob-to-any-file: + - 'packages/hono/*' + # For changes in the @lucide/icons package ❇️ lucide-icons: - changed-files: diff --git a/.github/workflows/lucide-hono.yml b/.github/workflows/lucide-hono.yml new file mode 100644 index 000000000..a693ef940 --- /dev/null +++ b/.github/workflows/lucide-hono.yml @@ -0,0 +1,87 @@ +name: Lucide Hono Checks + +on: + push: + branches: + - next + pull_request: + paths: + - packages/hono/** + - packages/shared/** + - tools/build-icons/** + - tools/rollup-plugins/** + - integrations/lucide-hono/** + - package.json + - pnpm-workspace.yaml + - pnpm-lock.yaml + +permissions: + contents: read + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + cache: 'pnpm' + node-version-file: 'package.json' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Build + run: pnpm --filter @lucide/hono build + + test: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + cache: 'pnpm' + node-version-file: 'package.json' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Test + run: pnpm --filter @lucide/hono test + + typecheck: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + cache: 'pnpm' + node-version-file: 'package.json' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Typecheck + run: pnpm --filter @lucide/hono typecheck + + integration: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + - uses: pnpm/action-setup@ea17c68df8912ef543352723c149a84f56e3d413 # v6.1.0 + - uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 + with: + cache: 'pnpm' + node-version-file: 'package.json' + + - name: Install dependencies + run: pnpm install --frozen-lockfile + + - name: Install Chromium + run: pnpm --filter @lucide/integration-hono-vite exec playwright install --with-deps chromium + + - name: Run integration checks + run: pnpm test:integrations:hono diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3e74ed570..b0d98b9d7 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -52,6 +52,7 @@ jobs: 'lucide-solid', '@lucide/angular', '@lucide/astro', + '@lucide/hono', '@lucide/icons', '@lucide/solid', '@lucide/svelte', diff --git a/README.md b/README.md index b0da062d6..cdc017379 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ Lucide is an open-source icon library that provides 1600+ vector (svg) files for | React Native logo | **`lucide-react-native`** | [![npm](https://img.shields.io/npm/v/lucide-react-native)](https://www.npmjs.com/package/lucide-react-native) | ![NPM Downloads](https://img.shields.io/npm/dw/lucide-react-native) | [Docs](https://lucide.dev/guide/react-native) · [Source](./packages/lucide-react-native) | | Angular logo | **`@lucide/angular`** | [![npm](https://img.shields.io/npm/v/@lucide/angular)](https://www.npmjs.com/package/@lucide/angular) | ![NPM Downloads](https://img.shields.io/npm/dw/@lucide/angular) | [Docs](https://lucide.dev/guide/angular) · [Source](./packages/angular) | | Astro logo | **`@lucide/astro`** | [![npm](https://img.shields.io/npm/v/@lucide/astro)](https://www.npmjs.com/package/@lucide/astro) | ![NPM Downloads](https://img.shields.io/npm/dw/@lucide/astro) | [Docs](https://lucide.dev/guide/astro) · [Source](./packages/astro) | +| Hono logo | **`@lucide/hono`** | [![npm](https://img.shields.io/npm/v/@lucide/hono)](https://www.npmjs.com/package/@lucide/hono) | ![NPM Downloads](https://img.shields.io/npm/dw/@lucide/hono) | [Docs](https://lucide.dev/guide/hono) · [Source](./packages/hono) | | SVG logo | **`lucide-static`** | [![npm](https://img.shields.io/npm/v/lucide-static)](https://www.npmjs.com/package/lucide-static) | ![NPM Downloads](https://img.shields.io/npm/dw/lucide-static) | [Docs](https://lucide.dev/guide/static) · [Source](./packages/lucide-static) | ### Figma diff --git a/docs/.vitepress/data/packageData.json b/docs/.vitepress/data/packageData.json index 6009b6f2e..ad027abdd 100644 --- a/docs/.vitepress/data/packageData.json +++ b/docs/.vitepress/data/packageData.json @@ -174,6 +174,24 @@ } ] }, + "@lucide/hono": { + "docsAlias": "hono", + "packageDirname": "hono", + "order": 10, + "icon": "hono", + "shields": [ + { + "alt": "npm", + "src": "https://img.shields.io/npm/v/@lucide/hono", + "href": "https://www.npmjs.com/package/@lucide/hono" + }, + { + "alt": "npm", + "src": "https://img.shields.io/npm/dw/@lucide/hono", + "href": "https://www.npmjs.com/package/@lucide/hono" + } + ] + }, "lucide-static": { "order": 10, "icon": "svg", diff --git a/docs/.vitepress/sidebar/hono.ts b/docs/.vitepress/sidebar/hono.ts new file mode 100644 index 000000000..5cd4ae2b9 --- /dev/null +++ b/docs/.vitepress/sidebar/hono.ts @@ -0,0 +1,77 @@ +import { DefaultTheme } from 'vitepress'; + +export const honoSidebar = [ + { + items: [ + { + text: 'Overview', + link: '/guide/hono/', + }, + { + text: 'Getting started', + link: '/guide/hono/getting-started', + desc: 'Learn how to get started with Lucide for Hono.', + }, + ], + }, + { + text: 'Basics', + items: [ + { + text: 'Color', + desc: 'Adjust the color of your icons', + link: '/guide/hono/basics/color', + }, + { + text: 'Sizing', + desc: 'Adjust the size of your icons', + link: '/guide/hono/basics/sizing', + }, + { + text: 'Stroke width', + desc: 'Adjust the stroke width of your icons', + link: '/guide/hono/basics/stroke-width', + }, + ], + }, + { + text: 'Advanced', + items: [ + { + text: 'Typescript', + link: '/guide/hono/advanced/typescript', + desc: 'All exported types and how to use them', + }, + { + text: 'Accessibility', + link: '/guide/hono/advanced/accessibility', + desc: 'Making your icons accessible', + }, + { + text: 'Global styling', + link: '/guide/hono/advanced/global-styling', + desc: 'Apply global styles to all icons', + }, + { + text: 'With Lucide Lab', + link: '/guide/hono/advanced/with-lucide-lab', + desc: 'Using lucide-lab with @lucide/hono', + }, + ], + }, + { + text: 'Resources', + items: [ + { + text: 'Accessibility in depth', + link: '/how-to/accessibility', + desc: 'Accessibility best practices', + }, + { + text: 'VSCode', + link: '/guide/vscode', + desc: 'VSCode and Lucide', + }, + ], + }, +] satisfies DefaultTheme.SidebarItem[] & { items: { desc?: string }[] }[]; diff --git a/docs/.vitepress/sidebar/index.ts b/docs/.vitepress/sidebar/index.ts index 889afb2af..1b7c88786 100644 --- a/docs/.vitepress/sidebar/index.ts +++ b/docs/.vitepress/sidebar/index.ts @@ -7,6 +7,7 @@ import { solidSidebar } from './solid.ts'; import { preactSidebar } from './preact.ts'; import { reactNativeSidebar } from './react-native.ts'; import { astroSidebar } from './astro.ts'; +import { honoSidebar } from './hono.ts'; import { resourcesSidebar } from './resources.ts'; import { angularSidebar } from './angular.ts'; import { lucideStaticSidebar } from './static.ts'; @@ -32,6 +33,7 @@ const sidebar: Sidebar = { '/guide/svelte/': svelteSidebar, '/guide/solid/': solidSidebar, '/guide/astro/': astroSidebar, + '/guide/hono/': honoSidebar, '/guide/preact/': preactSidebar, '/guide/react-native/': reactNativeSidebar, '/guide/angular/': angularSidebar, diff --git a/docs/.vitepress/theme/components/guide/FrameworkSelect.vue b/docs/.vitepress/theme/components/guide/FrameworkSelect.vue index f9171c114..ab375df9d 100644 --- a/docs/.vitepress/theme/components/guide/FrameworkSelect.vue +++ b/docs/.vitepress/theme/components/guide/FrameworkSelect.vue @@ -35,6 +35,7 @@ const frameworks: Framework[] = [ iconDark: '/framework-logos/astro-dark.svg', value: '/guide/astro/', }, + { name: 'Hono', icon: '/framework-logos/hono.svg', value: '/guide/hono/' }, { name: 'Static', icon: '/framework-logos/svg.svg', value: '/guide/static/' }, ]; diff --git a/docs/.vitepress/theme/components/home/HomePackagesSection.data.ts b/docs/.vitepress/theme/components/home/HomePackagesSection.data.ts index 04cfd9f44..6e0a23316 100644 --- a/docs/.vitepress/theme/components/home/HomePackagesSection.data.ts +++ b/docs/.vitepress/theme/components/home/HomePackagesSection.data.ts @@ -51,6 +51,12 @@ const loader = { label: 'Lucide documentation for Astro', path: '/guide/astro/', }, + { + name: 'lucide-hono', + logo: '/framework-logos/hono.svg', + label: 'Lucide documentation for Hono', + path: '/guide/hono/', + }, { name: 'lucide-react-native', logo: '/framework-logos/react-native.svg', diff --git a/docs/guide/hono/advanced/accessibility.md b/docs/guide/hono/advanced/accessibility.md new file mode 100644 index 000000000..043503d6f --- /dev/null +++ b/docs/guide/hono/advanced/accessibility.md @@ -0,0 +1,52 @@ +--- +title: Accessibility - Hono +description: Best practices for accessible icons in your application. +--- + + + +# Accessibility + +Lucide icons ship with `aria-hidden="true"` by default. In almost all cases this is exactly what you want. + +## Should icons be accessible? + +Most of the time, icons are used purely for decoration or visual reinforcement. Exposing decorative icons to assistive technologies can create unnecessary noise for screen reader users. + +For a broader explanation of this, and other best practices on how to use icons accessibly in your application, please refer to our detailed guide on accessibility: + + + +Only if an icon **conveys essential meaning on its own** should it be made accessible. The sections below explain how to do that in Hono. + +## Making an icon accessible + +To expose an icon to assistive technologies, provide an accessible name by passing the `aria-label` prop to the icon component, or by passing a `title` element as a child and referencing it with `role="img"` and `aria-labelledby`. + +Passing an `aria-*`, `role` or `title` prop removes the `aria-hidden` attribute and makes the icon visible to screen readers. A `title` child on its own does not: without those props the icon stays hidden. + +```tsx + + This is my house + + +// or + + +``` + +Choose a label that clearly describes the meaning of the icon or the action it represents in the context of your application. + +## Accessible icon buttons + +When an icon is used inside a button, the accessible label should usually be applied to the button itself, and not the icon. + +```tsx + +``` + +This ensures assistive technologies describe the interactive element, rather than the decorative graphic inside it. diff --git a/docs/guide/hono/advanced/global-styling.md b/docs/guide/hono/advanced/global-styling.md new file mode 100644 index 000000000..695ba7647 --- /dev/null +++ b/docs/guide/hono/advanced/global-styling.md @@ -0,0 +1,72 @@ +--- +title: Global Styling - Hono +description: Learn how to style all Lucide icons globally in your Hono application using CSS or the Lucide context provider. +--- + +# Global Styling + +Adjusting icons can be done by using [color](../basics/color.md), [size](../basics/sizing.md) and [stroke width](../basics/stroke-width.md). +To style all icons globally, you can either use CSS, or use a context provider. + +We recommend using CSS for global styling, as it is the most straightforward way to achieve this. +But using CSS prevents you from using props like `size`, `color` and `strokeWidth` on individual icons, since CSS specificity will override these props, to be able to use the props on individual ones you need to use the Lucide context provider. + +## Context Provider + +For global styling using a context provider, you can use the `LucideProvider` component that is provided by the `@lucide/hono` package. + +```tsx +import { Hono } from 'hono'; +import { LucideProvider, House } from '@lucide/hono'; + +const app = new Hono(); + +app.get('/', (c) => { + return c.html( + + + , + ); +}); +``` + +This will apply the `color`, `size` and `strokeWidth` props to all icons that are children of the `LucideProvider`. + +## Style by using CSS + +Styling icons is easy to accomplish using CSS. + +Every icon has a class attribute applied called `lucide`. This class name can be used in the CSS file to target all icons that are being used within the app. + +- The **color** of the icons can be changed using the [`color`](https://developer.mozilla.org/en-US/docs/Web/CSS/color) CSS property. +- The **size** of the icons can be changed using [`width`](https://developer.mozilla.org/en-US/docs/Web/CSS/width) and [`height`](https://developer.mozilla.org/en-US/docs/Web/CSS/height) CSS properties. +- The **stroke width** of the icons can be changed using the [`stroke-width`](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/stroke-width) CSS property. + +```css +.lucide { + color: #ffadff; + width: 56px; + height: 56px; + stroke-width: 1px; +} +``` + +### Non-scaling strokes + +For global non-scaling stroke width styling the `vector-effect: non-scaling-stroke` CSS property can be applied to the children. This will keep the stroke-width the same size no matter the size of the icon. See [non-scaling strokes](../basics/stroke-width.md#non-scaling-strokes) for more info. + +```css +.lucide { + width: 48px; + height: 48px; + stroke-width: 1.5; +} + +.lucide * { + vector-effect: non-scaling-stroke; +} +``` diff --git a/docs/guide/hono/advanced/typescript.md b/docs/guide/hono/advanced/typescript.md new file mode 100644 index 000000000..a3b1e3616 --- /dev/null +++ b/docs/guide/hono/advanced/typescript.md @@ -0,0 +1,111 @@ +--- +title: TypeScript - Hono +description: Learn about the different types exported by the `@lucide/hono` package and how to use them in your Hono application. +--- + +# TypeScript + +List of exported types from the `@lucide/hono` package. +These can be used to type your components when using Lucide icons in a TypeScript Hono project. + +## `LucideProps` + +Exports all props that can be passed to an icon component and any other SVG attributes, see: [SVG Presentation Attributes on MDN](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/Presentation). + +```ts +interface LucideProps { + size?: number | string; + color?: string; + strokeWidth?: number | string; + nonScalingStroke?: boolean; + [key: string]: any; // Any other SVG attributes +} +``` + +### Using `LucideProps` + +You can use the `LucideProps` interface to type your custom icon components or when you need to work with icon props. + +```tsx +import { Camera, type LucideProps } from '@lucide/hono'; + +const WrapIcon = (props: LucideProps) => { + return ; +}; + +export default WrapIcon; +``` + +## `LucideIcon` + +Type for individual icon components. + +```ts +import type { FC } from 'hono/jsx'; + +type LucideIcon = FC; +``` + +### Using `LucideIcon` + +You can use the `LucideIcon` type when you need to work with icon components directly. + +```tsx +import { House, Library, Cog, type LucideIcon } from '@lucide/hono'; + +type MenuItem = { + name: string; + href: string; + icon: LucideIcon; +}; + +const menuItems: MenuItem[] = [ + { name: 'Home', href: '/', icon: House }, + { name: 'Blog', href: '/blog', icon: Library }, + { name: 'Projects', href: '/projects', icon: Cog }, +]; + +const Menu = () => ( + +); +``` + +## `LucideIconNode` + +Type for the raw SVG structure of an icon. This is an array of SVG elements and their attributes to render the icon. +Not commonly used directly in application code. But can be useful for advanced use cases, such as using custom icons or with Lucide Lab. + +```ts +type LucideIconNode = [elementName: string, attrs: Record]; +``` + +### Using `LucideIconNode` + +You can use the `LucideIconNode` type when you need to work with the raw SVG structure of an icon. + +```tsx +import { Icon, type LucideIconNode } from '@lucide/hono'; + +const customIcon: LucideIconNode[] = [ + ['circle', { cx: 12, cy: 12, r: 10 }], + ['line', { x1: 12, y1: 8, x2: 12, y2: 12 }], + ['line', { x1: 12, y1: 16, x2: 12, y2: 16 }], +]; + +const MyIcon = () => { + return ( + + ); +}; +``` diff --git a/docs/guide/hono/advanced/with-lucide-lab.md b/docs/guide/hono/advanced/with-lucide-lab.md new file mode 100644 index 000000000..47633007c --- /dev/null +++ b/docs/guide/hono/advanced/with-lucide-lab.md @@ -0,0 +1,30 @@ +--- +title: With Lucide Lab or custom icons - Hono +description: Learn how to use Lucide Lab or custom icons in your Hono applications using the Icon component. +--- + +# With Lucide Lab or custom icons + +[Lucide Lab](https://github.com/lucide-icons/lucide-lab) is a collection of icons that are not part of the Lucide main library. + +They can be used by using the `Icon` component. +All props like regular lucide icons can be passed to adjust the icon appearance. + +## Using the `Icon` component + +This creates a single icon based on the iconNode passed and renders a Lucide icon component. + +```tsx +import { Icon } from '@lucide/hono'; +import { burger, sausage } from '@lucide/lab'; + +const App = () => ( + <> + + + +); +``` diff --git a/docs/guide/hono/basics/color.md b/docs/guide/hono/basics/color.md new file mode 100644 index 000000000..ac41551e5 --- /dev/null +++ b/docs/guide/hono/basics/color.md @@ -0,0 +1,41 @@ +--- +title: Color - Hono +description: Learn how to customize the color of Lucide icons in your Hono applications using the color prop and CSS. +--- + +# Color + +By default, all icons have the color value: `currentColor`. This keyword uses the element's computed text `color` value to represent the icon color. + +Read more about [`currentColor` on MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value#currentcolor_keyword). + +## Adjust the color using the `color` prop + +The color can be adjusted by passing the color prop to the element. + +```tsx +import { Smile } from '@lucide/hono'; + +const Page = () => { + return ; +}; +``` + +## Using parent elements text color value + +Because the color of lucide icons uses `currentColor`, the color of the icon depends on the computed `color` of the element, or it inherits it from its parent. + +For example, if a parent element's color value is `#fff` and one of the children is a lucide icon, the color of the icon will be rendered as `#fff`. This is browser native behavior. + +```tsx +import { ThumbsUp } from '@lucide/hono'; + +const LikeButton = () => { + return ( + + ); +}; +``` diff --git a/docs/guide/hono/basics/sizing.md b/docs/guide/hono/basics/sizing.md new file mode 100644 index 000000000..6835c76ec --- /dev/null +++ b/docs/guide/hono/basics/sizing.md @@ -0,0 +1,91 @@ +--- +title: Sizing - Hono +description: Learn how to adjust the size of Lucide icons in your Hono applications using the size prop and CSS. +--- + +# Sizing + +By default, the size of all icons is `24px` by `24px`. The size is adjustable using the `size` prop and CSS. + +## Adjusting the icon size using the `size` prop + +```tsx +import { Landmark } from '@lucide/hono'; + +const Page = () => { + return ; +}; +``` + +## Adjusting the icon size via CSS + +The CSS properties `width` and `height` can be used to adjust the icon size. + +```tsx +import { Beer } from '@lucide/hono'; +import { css, Style } from 'hono/css'; + +const beerIcon = css` + width: 64px; + height: 64px; +`; + +const Page = () => { + return ( + <> +