本文へスキップ
Ginga UI
Ginga UI
English

はじめに

  • 概要
  • クイックスタート
  • テーマ生成
  • 要素の差し替え
  • 全コンポーネント

フォーム

  • Button
  • Checkbox
  • Input
  • Radio
  • Questionnaire
  • SegmentedControl
  • Select
  • ComboBox
  • NumberField
  • SearchField
  • Slider
  • Switch
  • FormControl

表示

  • Accordion
  • Alert
  • AlertDialog
  • Badge
  • CodeBlock
  • Card
  • Dialog
  • Drawer
  • Image
  • List
  • Popover
  • Menu
  • Tooltip
  • Table
  • Tab
  • Toast
  • Trace

タイポグラフィ

  • Heading
  • Paragraph

ナビゲーション

  • Anchor

レイアウト

  • Box

リソース

  • 変更履歴
  • GitHub(新しいタブで開く)

ロゴ: Twemoji(新しいタブで開く) (CC-BY 4.0)

Image

画像を表示するコンポーネント。

Storybook で見る(新しいタブで開く)

インストール

import { Image } from "@ginga-ui/core";

基本的な使い方

シンプルな画像の使用例です。

美しい山の風景
image.tsx
image.module.css
import { Image } from "@ginga-ui/core";
import styles from "./image.module.css";

export function BasicExample() {
  return (
    <Image
      src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4"
      alt="美しい山の風景"
      className={styles.basicImage}
    />
  );
}

アバター

アバター画像の例です。

ユーザーアバターユーザーアバターユーザーアバター
image.tsx
image.module.css
import { Image } from "@ginga-ui/core";
import styles from "./image.module.css";

export function AvatarExample() {
  return (
    <div className={styles.avatars}>
      <Image
        src="https://images.unsplash.com/photo-1535713875002-d1d0cf377fde"
        alt="ユーザーアバター"
        variant="avatar"
        className={styles.avatarSmall}
      />
      <Image
        src="https://images.unsplash.com/photo-1494790108377-be9c29b29330"
        alt="ユーザーアバター"
        variant="avatar"
        className={styles.avatarMedium}
      />
      <Image
        src="https://images.unsplash.com/photo-1599566150163-29194dcaad36"
        alt="ユーザーアバター"
        variant="avatar"
        className={styles.avatarLarge}
      />
    </div>
  );
}

サイズ

様々なサイズの画像を表示します。

小サイズ中サイズ
image.tsx
image.module.css
import { Image } from "@ginga-ui/core";
import styles from "./image.module.css";

export function SizesExample() {
  return (
    <div className={styles.sizes}>
      <Image
        src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4"
        alt="小サイズ"
        className={styles.smallImage}
      />
      <Image
        src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4"
        alt="中サイズ"
        className={styles.mediumImage}
      />
    </div>
  );
}

角丸

角丸の画像を表示します。

角丸の画像
image.tsx
image.module.css
import { Image } from "@ginga-ui/core";
import styles from "./image.module.css";

export function RoundedExample() {
  return (
    <Image
      src="https://images.unsplash.com/photo-1506905925346-21bda4d32df4"
      alt="角丸の画像"
      className={styles.roundedImage}
    />
  );
}

Props

Image

名前型既定値説明
altstring-必須のpropsです。代替テキスト。装飾目的の画像には "" を渡します。
variant"default" | "avatar""default""avatar" を指定すると円形に切り抜いて表示します。
render(props) => ReactElement-ルート要素を差し替える関数。受け取った props を渡した要素(next/link など)を返します。

上記に加えて、HTML の img(新しいタブで開く) 要素の属性を受け取ります。