mui / mui/material-ui

[breadcrumbs] Support for leading separator (/)

Open
#46,486 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

has workaround scope: breadcrumbs type: new feature waiting for 👍
Dominant language
JavaScript
Stars
99.1k
Forks
32.5k
Avg merge
2d 17h
Merged PRs (30d)
106

Description

Summary

I would be grateful to see a new prop for <Breadcrumbs>, namely, showLeadingSeparator, or however you want to call it so that, the default breadcrumbs behaviour would include a leading / like here:

Image

My workaround is to add prepend an empty string "" to the pathSegments like:

const pathSegments = showHome
    ? ["#", ...pathname.split("/").filter(Boolean)]
    : ["", ...pathname.split("/").filter(Boolean)];

  const renderBreadcrumbItem = (value, to, index) => {
  // SNIP
  };

  return (
    <Breadcrumbs aria-label="breadcrumb" maxItems={isMdUp ? 8 : 2}>
      {pathSegments.map((value, index) => {
        const to =
          showHome && index === 0
            ? "/dashboard"
            : `/${pathSegments.slice(1, index + 1).join("/")}`;
        return renderBreadcrumbItem(value, to, index);
      })}
    </Breadcrumbs>
  );
};

As you can clearly see this workaround is leading to issues with v-align and is not very DX. Adding the suggested prop would solve this.

Examples

No response

Motivation

No response

Search keywords: breadcrumb, home, /

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Breadcrumbs component entry point and review how its children and separators are rendered. Use the reported leading-separator behavior and the supplied workaround as the acceptance target, then check the component's existing tests if available to verify the new prop without affecting default behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, react
Domain
frontend
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.