Skip to content

大小

默认情况下,所有图标的大小均为 24px × 24px。可以通过 size 属性和 CSS 来调整大小。

使用 size 属性调整图标大小

import { Landmark } from "lucide-react";

function App() {
  return (
    <div className="app">
      <Landmark size={64} />
    </div>
  );
}

export default App;

通过 CSS 调整图标大小

可以使用 CSS 属性 widthheight 来调整图标大小。

.my-beer-icon {
  /* Change this! */
  width: 64px;
  height: 64px;
}

基于字体大小动态更改图标大小

可以基于字体大小来调整图标大小。这可以通过使用 em 单位来实现。有关 em 单位 的更多信息,请参阅此MDN 文章

.my-icon {
  /* Icon size will relative to font-size of .text-wrapper */
  width: 1em;
  height: 1em;
}

.text-wrapper {
  /* Change this! */
  font-size: 96px;

  /* layout stuff */
  display: flex;
  gap: 0.25em;
  align-items: center;
}

使用 Tailwind 调整大小

可以使用 h-*w-* 实用程序来调整图标的大小。

import { PartyPopper } from "lucide-react";

function App() {
  return (
    <div>
      <PartyPopper className="w-24 h-24" />
    </div>
  );
}

export default App;