Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Sushi RS

Edit Component

🍣 Sushi RS Yew Usage

Adding Sushi RS to your Yew project is simple:

  1. Make sure your project is set up with Yew. Follow their Getting Started Guide for setup instructions.

  2. Add the Sushi RS component to your dependencies:

    cargo add sushi-rs --features=yew
    
  3. Import and use the Sushi component.

🛠️ Usage

use yew::prelude::*;
use sushi_rs::yew::Sushi;
use sushi_rs::common::{SushiShape, SushiState, SushiView, Ingredient, SushiOuterSheet, SushiSize, NORI_COLOR};

#[function_component(App)]
pub fn app() -> Html {
    html! {
        <Sushi
            id="salmon-maki"
            name="Salmon Maki"
            shape={SushiShape::Circular}
            state={SushiState::Rolled}
            view={SushiView::Top}
            ingredients={vec![Ingredient::Salmon]}
            outer_sheet={SushiOuterSheet { color: NORI_COLOR.into(), thickness: 10.0 }}
            size={SushiSize { width: 120.0, height: 120.0 }}
        />
    }
}
use yew::prelude::*;
use sushi_rs::yew::SushiGallery;
use sushi_rs::common::default_sushi_gallery;

#[function_component(App)]
pub fn app() -> Html {
    html! {
        <SushiGallery items={default_sushi_gallery()} />
    }
}

🔧 Props

Sushi Component

PropTypeDescriptionDefault
idStringSVG namespace ID"sushi"
nameStringDisplay name / ARIA label"Custom Roll"
shapeSushiShapeSilhouette shapeCircular
stateSushiStateRolled or ExplodedRolled
viewSushiViewTop or FrontTop
ingredientsVec<Ingredient>Inner fillings[Salmon]
outer_sheetSushiOuterSheetNori colour + thicknessnori defaults
sizeSushiSizeWidth × height in px120×120
rice_colorOption<String>Custom rice colourcream-white
top_edgeOption<TopEdgeDecoration>Rim decorationNone
scalef64Uniform scale factor1.0
class&'static strExtra CSS class""
style&'static strInline wrapper styleinline-block

SushiShape Enum

VariantDescription
CircularRound maki / gunkan roll
SquareRectangular tamago / oshi
TriangularTriangular onigiri
OvalNigiri hand-pressed shape

Ingredient Enum

VariantLabelEmoji
SalmonSalmon🐟
TunaTuna🐠
AvocadoAvocado🥑
EggTamago Egg🥚
RedCaviarRed Caviar🔴
BlackCaviarBlack Caviar⚫
CucumberCucumber🥒
CrabCrab🦀
ShrimpShrimp🍤
MangoMango🥭
CreamCheeseCream Cheese🧀
WasabiWasabi🌿

TopEdgeDecoration

FieldTypeDescription
edge_typeTopEdgeTypeNone, RedCaviar, BlackCaviar, Sesame, Herbs, Tobiko
colorOption<String>Override colour for herbs

🧱 Layout Structure

<div class="sushi-wrapper" role="figure">
  <svg ...>
    ← rolled view
    <defs>...</defs>
    <!-- nori + rice + ingredients -->
  </svg>
</div>

or in exploded state:

<div class="sushi-exploded-row" role="img">
  <div class="sushi-exploded-part">Nori SVG</div>
  +
  <div class="sushi-exploded-part">Rice SVG</div>
  +
  <div class="sushi-exploded-part">Ingredient SVG ...</div>
</div>

💡 Notes

  • Multiple ingredients are rendered as equal pie-slices with individual <title> elements.
  • The scale prop multiplies both size and sheet thickness uniformly.
  • SushiState::Exploded ignores shape and view and renders all layers side by side.
  • All SVG groups carry role="img" and aria-label via <title>.

Usage

CLI Usage

You can import Sushi RS directly into your project to customize and modify it using the opensass cli:

os add sushi-rs yew