web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

Creating a lookalike PCF control replacing standard TextBox

(0) ShareShare
ReportReport
Posted on by 40

Hi,

Pretty new to PCF controls and not really an HTML/CSS guy.

I created a pct control that includes an input control that will be used as a password entry box.

Purpose is that it looks & feel like the standard textbox, but I'm unable to achieve this.

There are two things that are different compared to the standard textbox.

- It does not draw a box around when focused

- it does not autosize horizontally

Any suggestion on how to tweak this PCF so that it resembles the standard controls?

public init(context: ComponentFramework.Context<IInputs>, notifyOutputChanged: () => void, state: ComponentFramework.Dictionary, container:HTMLDivElement): void
{

this._notifyOutputChanged = notifyOutputChanged;

// Create HTML text input element
this._inputElement = document.createElement("input");
this._inputElement.setAttribute("class", "passwordControl");
this._inputElement.setAttribute("type", "password");

// Extract the input value and update the input element
this._inputValue = context.parameters.boundProperty.raw || "";
this._inputElement.value = this._inputValue;

// Attach on change event handler
this._inputElement.addEventListener("blur", this.onBlur);

// Add the text input to the DOM
container.appendChild(this._inputElement);

this._container = container;
}

public updateView(context: ComponentFramework.Context<IInputs>): void {

// Extract the input value and update the input element
this._inputValue = context.parameters.boundProperty.raw || "";
this._inputElement.value = this._inputValue;
this._inputElement.setAttribute("type", "password");

// Set Width & Height
this._container.style.overflow = "hidden";
this._container.style.height = `${context.mode.allocatedHeight - 8}px`;
this._container.style.width = `${context.mode.allocatedWidth - 8}px`;
}

.passwordControl {
text-align: left;
border-width:0px;
border:none;
outline:none;
}

I have the same question (0)
  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Creating a lookalike PCF control replacing standard TextBox

    Hello,

    You should start using React/FluentUI. Check my post - butenko.pro/.../

  • Sven Peeters Itineris Profile Picture
    40 on at
    RE: Creating a lookalike PCF control replacing standard TextBox

    Hi,

    Would you mind sharing the code as a whole, having troubles figuring out how to render this new FluentUI TextField.

    I assume it's no longer in the init method but rather in the updateView method.

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: Creating a lookalike PCF control replacing standard TextBox

    Hello Sven,

    I wrote that blogpost a while ago and I don't have the laptop with the source code anymore. Also, I didn't put it on GitHub. So you will have to build that control yourself. If you experience any challenges do not hesitate to reach out to get some help.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 247

#2
Tom_Gioielli Profile Picture

Tom_Gioielli 166 Super User 2025 Season 2

#3
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 164

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans