Skip to content

Variable: HasRole ​

ts
const HasRole: DefineComponent<ExtractPropTypes<{
  allOf: {
     default: undefined;
     type: PropType<NameList>;
  };
  anyOf: {
     default: undefined;
     type: PropType<NameList>;
  };
  not: {
     default: boolean;
     type: BooleanConstructor;
  };
  role: {
     default: undefined;
     type: PropType<NameList>;
  };
}>, () => 
  | VNode<RendererNode, RendererElement, {
[key: string]: any;
}>[]
  | null, {
}, {
}, {
}, ComponentOptionsMixin, ComponentOptionsMixin, {
}, string, PublicProps, ToResolvedProps<ExtractPropTypes<{
  allOf: {
     default: undefined;
     type: PropType<NameList>;
  };
  anyOf: {
     default: undefined;
     type: PropType<NameList>;
  };
  not: {
     default: boolean;
     type: BooleanConstructor;
  };
  role: {
     default: undefined;
     type: PropType<NameList>;
  };
}>, {
}>, {
  allOf: NameList;
  anyOf: NameList;
  not: boolean;
  role: NameList;
}, Slots, {
}, {
}, string, ComponentProvideOptions, true, {
}, any>;

Defined in: packages/vue/src/components.ts:60

Renders the default slot when the user has the role(s), otherwise the #fallback slot.

vue
<HasRole role="admin">...</HasRole>
<HasRole role="writer|editor">...</HasRole>
<HasRole :all-of="['writer', 'editor']">...</HasRole>

Released under the MIT License. Inspired by spatie/laravel-permission.