Skip to main content

CategoryDescription

Renders a category's full description with optional "Read more" / "Read less" truncation. Resolves the correct language entry from the Propeller Category object and renders it as HTML.

Usage

Basic

import CategoryDescription from "@/components/propeller/CategoryDescription";

<CategoryDescription category={category} language="NL" />

With truncation (default behavior)

<CategoryDescription
category={category}
language="NL"
collapsed={true}
maxLength={200}
/>

The description is truncated at word boundaries after 200 characters and a Read more button appears. Clicking it expands to the full HTML content; clicking Read less collapses it again.

Without truncation

<CategoryDescription category={category} language="NL" collapsed={false} />

Custom max length

<CategoryDescription category={category} language="NL" maxLength={400} />

Custom styling

<CategoryDescription
category={category}
language="NL"
className="border-b pb-4"
/>

Combined with GridTitle and CategoryShortDescription on a category page

<GridTitle title={categoryName} language="NL" />
<CategoryShortDescription category={category} language="NL" />
<CategoryDescription category={category} language="NL" maxLength={300} />

Configuration

Data

PropTypeRequiredDefaultDescription
categoryCategoryNoPropeller Category object. The component reads the description array of LocalizedString items
languagestringYesLanguage code (e.g. "NL", "EN") used to match the correct LocalizedString entry

Truncation

PropTypeRequiredDefaultDescription
collapsedbooleanNotrueWhen true, the description is truncated to maxLength characters with a toggle button
maxLengthnumberNo200Maximum number of plain-text characters before truncation kicks in. Only used when collapsed is true

Styling

PropTypeRequiredDefaultDescription
classNamestringNoExtra CSS class applied to the root div

Behavior

Language resolution

  1. Reads category.description -- an array of LocalizedString objects ({ language, value })
  2. Finds the entry where language matches the language prop
  3. Returns the value (HTML string), or an empty string if no match is found

Truncation (collapsed: true, the default)

  • Strips all HTML tags from the description to measure plain-text length
  • If the plain-text length exceeds maxLength, truncates at the last word boundary before the limit and appends an ellipsis character
  • The truncated view renders as plain text (no HTML); the expanded view renders the full HTML via dangerouslySetInnerHTML

Empty state

When the description is empty (no category prop, no matching language entry, or an empty value), the component renders nothing -- no wrapper element is added to the DOM.

Styling details

  • Root element: mb-6 bottom margin
  • Full description: prose prose-slate max-w-none text-muted-foreground
  • Toggle button: text-sm font-medium text-primary hover:underline

SDK Services

This component does not call any SDK service directly. It expects a Category object to be passed via props (typically fetched by CategoryService.getCategory() or a direct GraphQL query).

Category fields read

FieldSDK TypeDescription
descriptionLocalizedString[]Array of { language: string; value: string } entries. The component finds the entry matching the language prop and renders its value as HTML

GraphQL Queries and Mutations

When fetching a category, include the description field to supply this component with data:

query GetCategory($categoryId: Int!, $language: String) {
category(id: $categoryId) {
categoryId
name(language: $language) {
language
value
}
description(language: $language) {
language
value
}
}
}

The returned description array is passed directly as category.description.