logo
  • 指南
  • 配置
  • 插件
  • API
  • 示例
  • 社区
  • Modern.js 2.x 文档
  • 简体中文
    • 简体中文
    • English
    • 命令
      文件约定
      src/
      App.[tj]sx
      entry.[tj]s
      entry.server.[tj]sx
      modern.runtime.[tj]s
      routes/
      *.[server|node].[tj]sx
      api/
      lambda/*.[tj]s
      server/
      modern.server.[tj]s
      shared/
      config/
      html/
      favicon.*
      icon.*
      mock/
      public/
      upload/
      modern.config.[tj]s
      运行时
      Core
      createRoot
      render
      Router
      router
      SSR
      NoSSR
      renderStreaming
      renderString
      createRequestHandler
      BFF
      useHonoContext
      Utility
      CSS-In-JS API
      Head
      loadable
      📝 编辑此页面
      上一页useHonoContext下一页Head

      #CSS-In-JS API

      使用 Style Component 来编写组件 CSS。

      #使用姿势

      import styled from '@modern-js/plugin-styled-components/styled';

      #函数签名

      请看 styled-component API。

      #示例

      import styled from '@modern-js/plugin-styled-components/styled';
      
      const Button = styled.button`
        background: palevioletred;
        border-radius: 3px;
        border: none;
        color: white;
      `;
      
      const TomatoButton = styled(Button)`
        background: tomato;
      `;
      
      function ButtonExample() {
        return (
          <>
            <Button>I'm purple.</Button>
            <br />
            <TomatoButton>I'm red.</TomatoButton>
          </>
        );
      }