Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[table] configurable columns#681

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
nellicus wants to merge6 commits intomain
base:main
Choose a base branch
Loading
fromclick-ui-table-configurable-columns

Conversation

@nellicus
Copy link
Contributor

@nellicusnellicus commentedOct 13, 2025
edited
Loading

Add configurable column visibility to Table component

This PR adds the ability for users to show/hide optional columns in the Table component, with preferences automatically persisted to storage.

New Features

  • Column visibility toggle: Settings icon in the table header opens a popover to configure visible columns
  • Mandatory columns: Mark columns asmandatory: true to prevent them from being hidden
  • Persistent preferences: Column visibility choices are automatically saved and restored

New Props

TableHeaderType:

  • id?: string - Unique identifier for the column (auto-generated if not provided)
  • required?: boolean - If true, column cannot be hidden by the user
  • selected?: boolean - alternative torequired: if true, the non-required column will be rendered as optional andselected

Table:

  • enableColumnVisibility?: boolean - Enables the column visibility feature (default: false)
  • tableId?: string - Unique identifier for storing preferences (required when enableColumnVisibility is true)
  • onLoadColumnVisibility?: (tableId: string) => Record<string, boolean> - Optional custom function to load preferences (defaults to localStorage)
  • onSaveColumnVisibility?: (tableId: string, visibility: Record<string, boolean>) => void - Optional custom function to save preferences (defaults to localStorage)

Usage

<Tableheaders={[{id:"name",label:"Name",mandatory:true},// Always visible{id:"email",label:"Email"},// User can hide{id:"role",label:"Role"}// User can hide]}rows={rows}enableColumnVisibility={true}tableId="users-table"/>

By default, preferences are saved to localStorage with key click-ui-table-column-visibility-{tableId}. Optionally provide custom storage functions for alternative storage
mechanisms (API, IndexedDB, sessionStorage, etc.).

Backward Compatibility

✅ Fully backward compatible - existing tables continue to work unchanged. The feature is opt-in via enableColumnVisibility prop.

Screenshot 2025-10-13 at 16 14 56Screenshot 2025-10-13 at 16 15 02Screenshot 2025-10-13 at 16 15 07
click-ui-table-column-visibility.webm

@vercel
Copy link

vercelbot commentedOct 13, 2025
edited
Loading

The latest updates on your projects. Learn more aboutVercel for GitHub.

ProjectDeploymentPreviewCommentsUpdated (UTC)
click-uiReadyReadyPreviewCommentOct 15, 2025 3:58pm

…long as the string contains a quote that would have to be escaped otherwise
Copy link
Collaborator

@ariserariser left a comment
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

awesome job!
a few things I noticed:

sortDir?:SortDir;
sortPosition?:HorizontalDirection;
width?:string;
mandatory?:boolean;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

NP:
requried? a more common term, I think
or maybeconfigurable: false?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

changedhere

/>
))}
{actionsList.length>0&&<colwidth={(actionsList.length+1)*32+10}/>}
{enableColumnVisibility&&<colwidth={48}/>}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

this includes padding, making the actual width less than the button width

Image

Comment on lines +192 to +203
{enableColumnVisibility&&(
<StyledHeader
aria-label="Column visibility"
$size={size}
>
<ColumnVisibilityPopover
headers={headers}
visibleColumns={visibleColumns}
onVisibilityChange={onVisibilityChange}
/>
</StyledHeader>
)}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

we should merge this heading cell with the actions heading cell
here, the columns icon should be above the actions column:
Image

yes, we don't use these actions that much, and we should change how they are implemented
but still

</ActionsContainer>
</ActionsList>
)}
{enableColumnVisibility&&<TableData$size={size}/>}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

what is this?

<EllipsisContentcomponent="div">{label}</EllipsisContent>
</TableData>
))}
{visibleItems.map(({ label, ...cellProps},visibleIndex)=>{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

looks like on mobile we don't have a way to configure visible columns
we need to keep the button available somewhere


headers.forEach((header,index)=>{
constcolumnId=header.id||`column-${index}`;
// If mandatory, always visible. Otherwise, check stored preference (default true)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

do we have a way to mark columns as initially hidden?

nellicus reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

changedhere

>
<Checkbox
checked={isVisible}
disabled={isMandatory}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i can suggest using the lock icon instead of disabled checkbox for locked columns
smth like
Image

maybe not make it muted as well, not that it's something secondary, it's just not available for configuration

nellicus reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

changedhere

Comment on lines 986 to 993
<ColumnVisibilityHeader>
<Text
size="sm"
weight="semibold"
>
Columns
</Text>
</ColumnVisibilityHeader>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

don't think this heading serves any purpose, lets not add it?

nellicus reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

changedhere

display: flex;
align-items: center;
gap: 0.5rem;
cursor:${({ $disabled})=>($disabled ?"not-allowed" :"pointer")};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Actual interactive area doesn't match the visually interactive area.
You can click at the empty space in the row, and it'll work. But usualy a checkbox clickable area is limited to its label, where there's an actual text.

It's a good thing that the row is clickable, but let's add visual feedback to make it obvious: a hover effect for the whole row, sometimng similar to what we have in CheckboxMultiSelect, or Dropdown

size?:TableSize;
showHeader?:boolean;
rowHeight?:string;
tableId?:string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

when not specified, it will silently not do anything
we need to make it required when the primary prop is enabled

typeType=|{enabled:true;tableId:string;}|{enabled?:false;tableId?:never;};

<Popover.Trigger>
<IconButton
type="ghost"
icon="settings"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

i think I'm more used to seeing a gear icon in this context
but idk, this one works as well

nellicus reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

changedhere

…s the non required column), rename mandatory -> required, use lock icon for required col
@nellicusnellicus changed the title[table] column visibility[table] configurable columnsOct 17, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@ariserariserariser requested changes

@vineethasokvineethasokAwaiting requested review from vineethasok

@gjonesgjonesAwaiting requested review from gjones

@elizabetdevelizabetdevAwaiting requested review from elizabetdev

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@nellicus@ariser

[8]ページ先頭

©2009-2025 Movatter.jp